10-24-2013 11:49 AM
I am trying to write a program in LabVIEW that will continuously write three variables (Temperature (F), Temperature (C) and rate of change of temperature over change in time (C/s)) to a single file, in 3 seperate columns, as well as the corresponding time. I have been working on figuring it out for a few hours and can't figure anything out. I was wondering if it is possible, and if so, how?
Solved! Go to Solution.
10-24-2013 12:00 PM
All you need is append a tab delimited row of four values with each update. Where exactly do you have a problem?
10-24-2013 01:01 PM
I'm not entirely sure what do you mean by append a tab delimited row of four values with each update, as I am very new to the software. First of all, which function do you suggest I use? My whole program is inside of a while loop structure. I have formed the three output variables I want into a 1-D array using the build array function and connected that array to the Write To Spreadsheet File.vi function, but it seems like this function does not continuously write the values; I have to save it into a new file each iteration. I also tried connecting the array to a Write To Measurement file.vi function, saving to an excel file format, but that seemed to write each of the three variables in the same column.
10-24-2013 01:10 PM
Hello CrashMcLars1, and welcome to the forum!
The Write to Spreadsheet File function has an input named "append to file?" that defaults to false. If you wire a Boolean True value to this input, your values will be appended to the file rather than overwriting it.
Also- Ctrl+H or the question mark in the upper right corner of your block diagram will launch the Context Help window- very handy for seeing how a function works and what it expects for inputs!
Regards,
10-24-2013 01:10 PM - edited 10-24-2013 01:10 PM
"Write to spreadsheet" has a "append?" input. Wire a TRUE to it and it will append. Here's a very simple example.
10-24-2013 01:14 PM
Note that "write to spreadsheet file carries a lot of baggage, so if you are writing at a relatively high rate, it is better to open the file before the loop, append inside the loop as correctly formatted plain string, and close the file at the end.
You can open "Write to spreadsheet" by double-clicking and you'll see that it opens and closes the file with every write, which can be expensive and unecessary.
(If you need to write at a even higher rate, you should use a binary file, but that is beyond the scope of this discussion.)
10-24-2013 01:18 PM - edited 10-24-2013 01:20 PM
@altenbach wrote:
... so if you are writing at a relatively high rate, it is better to open the file before the loop, append inside the loop as correctly formatted plain string, and close the file at the end.
Here's a quick example for that.
Of course you should format the time stamp according to your specific requirements.
10-25-2013 03:44 PM
Awesome! the first file you have sent works very well for me and I have almost got what I want. If I save it as a text file and open it in notepad, I get 4 seperate columns. My only problem now is if I try to save it as an excel file, I get an error message when I try to open the file saying "Excel found unreadable content in 'Test2.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes." I clicked yes and Excel presents me with a dialog saying "Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded." So I end up with a blank excel spreadsheet. I understand I can copy and paste the variables from the text file into an Excel file, but ideally I would like to just be able to save it into an Excel file to begin with. Is there another way I could import the data into Excel? Is there some sort of additional software I need for Excel to properly read the data? Anyways, Thanks altenbach and outlaw for all the help so far. I really appreciate it.
10-25-2013 03:57 PM
Don't save it as an .xlsx. It is not an excel file. It is a text file.
So save it as a .txt or a .csv
10-25-2013 04:09 PM
Ok so if I want this data in an excel spreadsheet, what would be the best way to do that?