LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I add new values only to a column of a spreadsheet?

I have three "while loops" that are executed in parallel, two generate values and the third while loop write the values in a spreadsheet.
The run time of each while loop is different, to synchronize the three while loops I use a "Wait Until Next ms Multiple", but sometimes the same value is kept twice.
I think that a solution would be to add a "Write To Spreadsheet File" in the blocks that generate values, adding a new value in the wished column in each cycle, but I do not know like doing this.
I could keep the values in two arrays and add them in a same spreadsheet in different rows or columns, but I need save values in spreadsheet in each loop and not all values at the end of cycle.

Thanks.

German Garrigos.
0 Kudos
Message 1 of 3
(2,313 Views)
I think your three loops solution is probably better than putting different kinds of functions into one loop. Keeping data acquisition/generation separate from file i/o is usually better because the OS can interfere with timing on the file operations.

If you pass the data to the file loop via queues, place the data into shift registers, and only write to the file when you have equal amounts of data from each generator you should be able to keep things synchronized. You can write larger or smaller amounts as necessary to keep pace with the generators. If one of the generators gets way ahead of the other, you have to decide how to deal with that issue.

Writing to the second column of a three column spreadsheet can be tricky. It involves keeping pointers to the portions written and not written, reading the entire file into memory and overwriting the cells where new data goes and rewriting the entire file. This can get very slow for large files. If the file and data structures are simple enough it might be feasible to read only a portion of the file and overwrite it with new data, but that approach has lots of risks to the data.

Wait until next ms multiple is only reliable if the wait interval is sufficiently longer than the execution time (including random OS delays) of each loop. Look at the synchronization functions such as notifiers to synchronize your loops.

If you still have problems, post a simplified version of your program and someone will probably be able to suggest solutions.

Lynn
Message 2 of 3
(2,305 Views)
The solution that I have used has been to increase the values of an Array 1D for each variable that I want to store in a column (using shift registers), in a parallel "while loop" using local variables of the arrays 1D, I have formed an array 2D, now I write it in the file.
Thus it does not repeat values in the table since it crushes all the file whenever it writes in, because no add values.

Thanks.
Adios.
0 Kudos
Message 3 of 3
(2,273 Views)