LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert data to new row in csv Excel file

Hi,

I have created a subVI that writes 2 1D array( 1st: header, 2nd: data) to a csv Excel file using Write to Spreadsheet File. However every time it runs, it overwrites the old data.

But I want the new data to be written on the next row instead of the old data being overwritten. How do I do that?

0 Kudos
Message 1 of 5
(5,172 Views)

Every time you call that subVI, you overwrite the previous data with the header information (the first Export to Spreadsheet file) and then append a line of data (the second). You only want to write the header once, and append data multiple times.

 

You could either split this into two subVIs (one for file generation and header writing, another for appending) or, more preferably, use a state machine with initialise and write states that do the same thing.

 

Edit - also, Write to Spreadsheet File accepts only arrays of data, so there's no point bundling the inputs into a cluster, unbundling and then building an array of them.

---
CLA
0 Kudos
Message 2 of 5
(5,165 Views)

i would use 'check if file/folder exist' and a case statement...if false(write header), if true(just pass the file path through)

Excel report (SubVI)_BD.png

0 Kudos
Message 3 of 5
(5,151 Views)

And lets not forget about the Rube pointed out by the user thoult here.

As Christian Altenbach would say: "Do more with less code in less time" 🙂

 

Regards

Mondoni
0 Kudos
Message 4 of 5
(5,130 Views)

@joaopam wrote:

And lets not forget about the Rube pointed out by the user thoult here.

As Christian Altenbach would say: "Do more with less code in less time" 🙂

 

Regards


yeah... it was around midnight here when i posted, i looked at it and and and..................................im going to bed!

Message 5 of 5
(5,117 Views)