LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a cluster to a spreadsheet

Hi

I am generating some data from my measurement and need to write some data to a file. The measurement loops over two physical parameters that are varied in a nested loop (call them x and y) and the data has six values per (x,y) pair (call them mij1-6).

I wish to write a spreadsheet file with eight columns :

x1 y1 m111 m112 m113 m114 m115 m116
x1 y2 m121 m122 m123 m124 m125 m126
...

separated by spaces or tab characters.

How do I write the cluster xi yj mij1-6 above at each loop evaluation to a file ?

Second question - how does one add timestamp and header info (like o/p of some system info - username, etc.) ? This code is running on Linux, and I am not concerned about Windows portability.

Thanks.
Message 1 of 14
(4,876 Views)
I would like to add that I have tried converting the cluster to an array and then wiring the o/p to the 2D input of the Write to Spreadsheet VI. It leads to a broken wire - the o/p is a 1D array. I cannot wire that to the 1D pin because that will not do what I want (see my original post).
0 Kudos
Message 2 of 14
(4,857 Views)
Try Flatten to String and Unflatten From String in the data manipulation pallete.
0 Kudos
Message 3 of 14
(4,849 Views)
What doesn't work with writing a 1D array? with each iteration, you will write one row to the text file.
0 Kudos
Message 4 of 14
(4,843 Views)
Adding one row with 8 columns at a time is precisely what I am trying to do.

I have a cluster of these 8 numbers, properly ordered to start with. How do I add the contents of this cluster into a single row ? When I convert this cluster into an array, will it not give me a 8x1 array instead of a 1x8 array (which I want). I tested this by connecting the output of the array generated from the cluster to a Transpose 2D array VI and the wire breaks there as well. That proves that the o/p of the Cluster to Array VI is a 8x1 array, not a 1x8 array. Useless for adding a row.

Any suggestions welcome.
0 Kudos
Message 5 of 14
(4,837 Views)
A 1D array is a 1D array and there is no difference between 8x1 or 1x8. They are the same thing. Wiring a 1D array to a Transpose 2D Array of course doesn't work because it requires a 2D array input and you have a 1D array as an input. On the output of your Cluster to Array function, right click and select 'Create Indicator'. The 1D array can be visually shown as elements going down or across but it's the same identical data no matter how you display it.

Message Edited by Dennis Knutson on 09-26-2006 09:57 AM

0 Kudos
Message 6 of 14
(4,836 Views)
That is quite unusual (at least from what I know of array handling in Fortran and C). All right. If I wire it to the 2D array input of the Write To Spreadsheet VI, it breaks the wire, and if I wire it to the 1D array input, I thought it would probably write a single column into the file.

So, I went ahead an wrote a small VI with a cluster and array conversion. What you suggest does indeed work !

Thanks. If there is really no difference between 1x8 and 8x1 in Labview, then why does Labview still maintain the distinction between 1D arrays and 2D arrays ? Why not just define a 1D array as a 2D array with one row and be done with it ?
0 Kudos
Message 7 of 14
(4,828 Views)
You keep thinking there should be a difference between 1x8 and 8x1 and there's not in LabVIEW or any other language. A 1D array in LabVIEW is the same as Array[x] and a 2D array is the same as Array[x,y]. A single dimension is always a single dimension and you can call it a single row or a single column but it's the same. I think the confusion is over semantics and how do you describe a 1D array with words. I don't think of a 1D array as having a single row or a single column. If you have a line, the line has a single dimension called length. If the line is horizontal or vertical, it still has a single dimension so the 1x8 or 8x1 is just describing the visual look of your array on the front panel.
Message 8 of 14
(4,823 Views)
May not be in Labview, but whether you store stuff in columns or rows makes a BIG difference in memory access time in textual languages. Yes, I know that dimensionally speaking there should be no difference between 1x8 and 8x1, but the devil (in textual languages like Fortran and C) lies in the implementation details. In Matlab, you even get syntax errors if you try to mix the two (Fortran and C hide the internal implementation of a 1D array, but go to a 2D array, and the difference between order of access becomes tellingly apparent).

Anyways, its hard to let go of about 2 decades of thinking textually in just a week of using G 🙂

Message Edited by m-s on 09-26-2006 11:35 AM

0 Kudos
Message 9 of 14
(4,820 Views)
m-s wrote;
 
"Anyways, its hard to let go of about 2 decades of thinking textually in just a week of using G  "
 
"OUT OUT You demons of stupidity!" (Dilbert poster) Smiley Surprised
 
Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 14
(4,813 Views)