LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

may i write data to a spreadsheet file at different times

I'd like to write two sets of data at different times(not simutaniuosly)into the same spreadsheet file. I tried to re-open the spreadsheet file which i created when i wrote in the first set of data, to write in the second set of data. But it didn't work. I don't know what's wrong with my program. I have selected APPEND when I tried to write the second set of data in the old file.
0 Kudos
Message 1 of 11
(2,796 Views)
A couple questions, when you writing to the file the second time didn't work, what exactly happened? error message? original contents over written?

Second, how long is there between the first write to the file and the second write? Some things to check is whether the first write is closing the file when it finished, and did you by chance open the target file with some other program than LV between writing to it the first time and writing to it the second time? That will sometimes change the format of a file without you realizing it.

What is the format of the data in the file?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 11
(2,796 Views)
1.what happened is when i try the second write, i first open the old file and write, nothing of the second write appeared in the file.( the first write still there).
2. yes, i have opened the first write file with EXCEL to check if my write is ok. so the time between the two writes depends on the time between the running of the two writes( the functions are in different programs by now).
3.i think the"write to spreadsheet file vi" has closed the file after the first write.
4.the data format is as determined in the "write to spreadsheet file vi", byte stream?
0 Kudos
Message 3 of 11
(2,796 Views)
Do you get any errors when you try to perform the 2nd write?

The "write to spreadsheet file.vi" routine doesn't use a byte stream it just writes tab-delimited strings.

Can you post a copy of the code that you are using?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 11
(2,796 Views)
not nay errors appear.
the following is a similar easy copy of the program. I don't want to post my original program because too many subroutines.



Tanks a lot to Mikeporter
Download All
0 Kudos
Message 5 of 11
(2,796 Views)
As a start, the Open/Create/Replace function shouldn't be there since it is in the Write to Spreadsheet File function, you should be using a format string of %f to read and write all of the decimal places that you need, and you should define a TRUE for the append to file input of your Write to Spreadsheet.
0 Kudos
Message 6 of 11
(2,796 Views)
in fact i have chosen "append" in my program.(but here in this easy one i forgot). I have tried both "with open file vi " and "without open file vi" neither works.
0 Kudos
Message 7 of 11
(2,796 Views)
I'm sorry to be distractive that i did not see that in fact the second write was successful, but the data was appended to the end of my former data, which is not what i expected.(I expected my second set of data be saved to the first set of data side by side, not end to head). Now It seems that the only way to append data to an existing file side by side is to read all the data into LABVIEW program, append the two sets of data into one 2-D array and use "write to spreadsheet file vi" to write them to a new file. Is my understanding right?Do you have any better idea to achieve it?
0 Kudos
Message 8 of 11
(2,796 Views)
All I can say is that every time I run your VI with the changes I described, I append new data to the file. I saved the file you're writing too as a text file. Are you sure that this file on your system is plain text and nothing else has it open?
0 Kudos
Message 9 of 11
(2,796 Views)
yes, the data was appended at the end of my former file data.but I didn't notice it at first.

but Now the problem is how to append data side by side(not end to head.)

I mean if my former data ocuppies the first two columns in the spreadsheet, I hope to write the second set of data to the third and fourth columns(side by side),(not append the second set of data to column one and column two.)

That's what I don't know how to realize by "write to spreadsheet file vi", To my knowledge, "write to spreadsheet file vi" just can not finish such a function.
0 Kudos
Message 10 of 11
(2,552 Views)