LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write multiple rows and columns to spreadsheet

Solved!
Go to solution
Is there a way to write multiple rows and columns to spreadsheet, with the option to append data to the file, and create a new file if it doesn't exist?
I tried to write to spreadsheet vi, but I couldn't make it work.
It only lets me write multiple rows in the same column.
Can someone please give me an example?
Thanks in advance.
0 Kudos
Message 1 of 6
(5,571 Views)

Yes, you can do most of that easily. What is giving you problems? Can you show us you problem code?

 

The only expection is that you cannot easily add new columns to an existing delimited file, because elements of a new column are not adjacent (in memory or on disk), meaning that the entire file needs to be read, all data combined into a new copy, then written back to disk.

 

In contrast, appending rows is easy and the existing file data does not need to be touched.

0 Kudos
Message 2 of 6
(5,560 Views)

You can not append columns to the spreadsheet without rewriting the whole file:

Read file -> transpose array -> build array (add rows) -> transpose -> Write spreadsheet.

 

On disk spreadsheets (and other files) are one dimensional:

1  2  3  (new line) 4 5 6 (new line) 7 8 9 (end of file)

 

To insert columns it needs to move multiple parts of file. It is not a basic operation. It is possible to do it (not to load the whole file into memory), but it is much more complicated than above sequence.

 

 

0 Kudos
Message 3 of 6
(5,552 Views)

I will leave the code and the output in the description.

Download All
0 Kudos
Message 4 of 6
(5,530 Views)
Solution
Accepted by topic author Nando88

If you are going to use tab (\t) as the delimiter, then make the file a txt.  Then Excel will open it the way you want.

If you want to keep the csv extension, then use comma (,) as the delimiter.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 6
(5,516 Views)

@Nando88 wrote:

I will leave the code and the output in the description.


You are only showing two truncated pictures, one containing LabVIEW code with many overlapping items and wires coming from the outside. I don't see anything configured for appending to an existing file.

 

Attach the actual VI if you want our help. Thanks.

 

... and why are you calling the file *.csv if you use tab as delimiter? What's the display format of your string constants?

0 Kudos
Message 6 of 6
(5,514 Views)