LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write line to file

Hi guys,

               i'm trying to log data to an excel file, i want to have multiple labled colums of data and write a new line of data every second. I have written a program to do this but i'm sure its not the best way.

 

Ideally i would like to write a line at a time, but the only way i can mannage to do it its to collect all the data into an array, transpose it and keep writing the array to the file, this means the data allready in the file is simply over written by its self comming from the array and the new data is written in, the array just gets bigger and bigger esentialy storing all the data the file is storing.

 

I have attached a picture of the table my program creates as this is the layout i want to achive, but i want to update it a line at a time.

 

Any ideas ,Thanks Zac.

 

 

0 Kudos
Message 1 of 7
(2,761 Views)
Are you actually using ActiveX to write to an Excel workbook, or are you writing to a text file using the Write to Spreadsheet File function or the File I/O functions? If you're using ActiveX then you can write directly to any cell and/or range. If you're writing to a text file, the Write to Spreadsheet File function has an "append" input so you only need to create the array that consists of the line you want to write.
Message 2 of 7
(2,750 Views)

I'm using the "write to spreadsheet file" vi.

 

 

I have attached a picture of this part of the program, the flat sequence has 3 sequences 1 and a half are off screen but number 1 creates a file and writes some one off details to it, number 2 creates the colum titles and number 3 is the main one in the picture which saves the data.

 

*I know its messy.

 

** the data comes from the main VI as this is a SubVi.

 

Chees, Zac

0 Kudos
Message 3 of 7
(2,745 Views)

just to clarify, i have enabled the "append to file" option on the "write to spreadsheet file" vi, but the problem i have is my array is keeping all the data so when i write the array to file instead of appending a single line it appends a huge array full of data.

 

How can i update a single line array rather than simply adding to it ?

 

cheers zac 

0 Kudos
Message 4 of 7
(2,732 Views)

This appears to be the same program you asked about here and here.

 

If you're logging a new line at each iteration of the loop (it seems that you turn logging off/on with the Boolean control), then you do not need the previous information, so why are you trying to append to it? Are you trying to save the data in case logging is turned off, and then if logging gets turned back on, the data that didn't get written to file gets written? If so, what's the purpose of turning logging off? If you do not care about saving data while logging is turned off, then all of your shift registers are unnecessary, and all of the individual Build Array functions that are connected to your numeric controls are unnecessary. Simply take each numeric control into a single Build Array and feed that to the Write to Spreadsheet File function. 

Message 5 of 7
(2,727 Views)

just been having a play and i've got it sorted, its painfully simple.

 

thanks zac

 

 

0 Kudos
Message 6 of 7
(2,726 Views)

thanks, thats what i've just come to realise.

 

 

 

0 Kudos
Message 7 of 7
(2,721 Views)