06-24-2013 02:26 AM
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?
06-24-2013 02:42 AM - edited 06-24-2013 02:46 AM
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.
06-24-2013 03:28 AM - edited 06-24-2013 03:34 AM
i would use 'check if file/folder exist' and a case statement...if false(write header), if true(just pass the file path through)
06-24-2013 06:11 AM
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
06-24-2013 07:17 AM