LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing string and 1D array data to the same csv file

Solved!
Go to solution

Greetings,

I should note I am a LabVIEW novice. I realize this is probably not a problem for most. I would be grateful for any feedback you have. Previously, I have written data to a CSV by using the format into string function prior to writing characters to file function (see attached). This has worked fine but I am only able to write so many variables using the method or I get an error that is related to there being too many inputs (I believe). So, I typically perform this "method" several times for groups of variables so that it is at least operational. However, when I do this, I am not able to save all my variables to one CSV. I end up with 2 to 4 different CSVs even though the data corresponds. Ultimately, I am trying to write my data to one CSV but the first column of data would be string (for example, "subject 1_R_") while the rest of the columns would be numerical. Thank you!

 

0 Kudos
Message 1 of 4
(5,098 Views)

Well without seeing all of your code nobody is going to be able to help much beyond wild guesses and basic questions like:

 

Have you tried putting everything into an array and then writing the array to a file using the "Write Delimited Spreadsheet" VI? 

========================
=== Engineer Ambiguously ===
========================
Message 2 of 4
(5,084 Views)
Solution
Accepted by topic author exphys

You are writing a .CSV file -- this is a text file with (string) values separated by commas (to make columns), and "lines" separated by <EOL>.  So if you have a 2D array of strings, the first entry of each row being a string like "subject_1_R", and the remaining columns being string representations of the numbers in the first row of data.  Now repeat with the second row of data, putting the identifier in the first column and the data (formatted into strings) in the remaining columns of the row.  Repeat until you've converted all the data into a 2D array of strings.

 

Now look at Write Delimited Spreadsheet (the name of this function changed slightly in LabVIEW 2014 or 2015, but the basic functionality remains the same).  This is what RTSLVU was suggesting -- it is a very simple way to take 2D data and create a CSV file from it.

 

Bob Schor

Message 3 of 4
(5,044 Views)

It took me awhile, but I found a configuration that works. I do no think it is exactly the same code you were describing but it does what it needs to. All data is now saved on one text file. The advice provided definitely helped. Attached is an example of the approach I used. Unless I am missing something, this will work. 

0 Kudos
Message 4 of 4
(5,009 Views)