LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Append scalar values to text file

I plan to using following code structure:
 
Before while loop: use a open file function  to open a file for write
Within loop: I acquire current time, current DAQmx force, and current motor position, all are scalar values. I will add / append them to a text data file
After loop: close the file
 
I hope the data inside the text file to be arranged as following:
 
time     force      position
--------------------------------
t0          f0           p0
t1          f1           p1
t2          f2           p2
...          ...           ...
...          ...           ...
...          ...           ...
tn           fn          pn
the end of the file
 
My question is:
(1) what write function can accept scalar values for appendage within each iteration, similar as wavwform chart (not wavwform graph). I don't want to assemble all data to an array and then send to a file, since I have lots of data which may cause crash when assenmling large array.
 
(2) what's the way to make data inside the file arranged as I require?
 
Thanks a lot.
 
 
 
 
 
0 Kudos
Message 1 of 2
(2,799 Views)
Since you are writing to a text file, just format each line and then write to the file with "Append to File" = True.

Use the Number to string functions in the string palette to convert the numeric data to strings. Separate fields with tabs and put an "End of Line" at the end of each row. One string would look like: "t0"\t"f0"\t"p0"\r\n, where \t = tab, \r = carriage return, and \n = line feed.

Lynn
0 Kudos
Message 2 of 2
(2,791 Views)