LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write delimited spreadsheet

Solved!
Go to solution

I'm embarrassed to ask this but I'm terribly rusty with LabVIEW

 

If I'm outputting a 2D array into the file (Double precision numbers) Every for loop cycle

1 4
2 5
3 6
Using -write delimited spreadsheet Function

 

I get

1 4
2 5
3 6
1 4
2 5
3 6

After two cycles

 

What I want

1 4 1 4
2 5 2 5
3 6 3 6

 

How do I bring the second cycle back to the top of the file in alignment with the first data set?

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 5
(108 Views)

If performance isn't a concern, you could read the existing contents of the file, do some transposes, and then append the new array.

 

Darren_1-1759854563499.png

 

0 Kudos
Message 2 of 5
(80 Views)
Solution
Accepted by topic author LED47

You can only append rows, not columns. This is a consequence of the file layout.

 

On disk, the file looks like

 

1 4\n2 5\n3 6\n

after inserting columns, the file looks like

 

1 4 1 4\n2 5 2 5\n3 6 3 6

 

You need to build a larger 2D array in memory by concatenating each cycle’s 2D array horizontally (column-wise), then write the final array to the file once.

 

build array columnwisebuild array columnwise

 

The alternative is to change the file layout. Or rewrite the file each iteration.

0 Kudos
Message 3 of 5
(75 Views)

That's the ticket...

 

Thank you to everyone

 

 

0 Kudos
Message 4 of 5
(58 Views)

@cordm wrote:

The alternative is to change the file layout.


I agree, change your code to append two rows with each iteration and document it. Even for a gigantic file, no existing data needs to ever be touched.

 

In particular, use low-level file i/o, open it before the loop, keep appending in the loop, and close when done.

 

You can always add a postprocessing step that generates the transposed file at the very end.

0 Kudos
Message 5 of 5
(9 Views)