09-05-2022 08:28 AM
Hello,
im using Write Multiple Columns With Write to Spreadsheet File VI - NI Community this example to write the data in csv file but im not getting results as expected. I have 3 output numbers and i want repeat while loop multiple for multiple iterations as im attaching here. but when i run the vi im getting only one value of iteration even im giving 5, 10, 15 or more iterations as input moreover the written values in also is only in one columns not in the different columns. can someone tell me what is the issue in it? and for corrections
thank you
Solved! Go to Solution.
09-05-2022 08:38 AM
Hi jeet,
the VI does exactly what you programmed to do!
You write the header row each iteration - and even more worse: you create a new file with each iteration…
You need to understand those examples before you start to modify them!
09-05-2022 08:38 AM
Hi,
With the first use of "Write to spreadsheet file" you are creating the file and adding value.
Second use you are adding value.
Then you are going to the next loop iteration and do it again, including the creation of the file by overwriting the old one.
You should create your file outside of this specific loop and only adding values there.
09-05-2022 08:48 AM
The red Cross means this VI is too old, it was created for LabVIEW 2012, you can replace the with the following VI
Regards,
FrankenChino
09-05-2022 09:22 AM - edited 09-05-2022 09:23 AM
Hi, gerdw
i made changes as you said.. now im getting data for all the iterations but not in the columns. can you tel me what is the wrong in the vi??? attaching the changes and output ..
thanks
09-05-2022 09:37 AM
For a csv file this is OK.
The interpreter has to know the delimiter and do the work to make it into columns. For a csv it will do it each time it sees a comma.
Now, depending of the file extension, your Excel will open it as a .xlsx and not doing that work.
To do it manually in Excel : Excel => Data => Convert => Delimiter = comma.
You can also choose the delimiter in LABView with a tabulation as delimiter and then no work to do in Excel, but your file is no more a real .csv.
09-05-2022 09:44 AM
Hi,
change the input as 2D array, change the data input also as 2D array as well, just try out, so you will finger out the mapping of columns and rows.
Regards,
FrankenChino
09-05-2022 10:09 AM
this worked thanks
09-06-2022 07:52 AM - edited 09-06-2022 07:54 AM
Let me suggest an alternative (that example is actually pretty bad).
You should not be using the Write To Delimited File inside of a loop. That VI opens the file, sets the file pointer, writes the data, and closes the file each time it is called. Instead, create the file before your loop, write inside as much as you want, and then close the file after the loop. This is SOOOOOOOO much more efficient.
Doing this will also remove the need to deal with arrays like you are. I chose to use the Format String instead of the concatenating as I think it is cleaner.
09-12-2022 06:48 AM
hello,
im attaching what im trying to do.. im writing data to CSV i as i explained before the and its working now i want to add one function in it. i want to use event structure or any similar function so if i press button save data then only it should save the data or else it should stay idle and it should not save the data in CSV file. can someone tell me how can i do it?
thank you