From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Append Column to Spreadsheet

Solved!
Go to solution

Hello, everyone.

 

As the title suggests, I'm looking to append a relative timestamp column to the spreadsheet I've created. I've had some difficulty with this due to the nature of the program, so let me go into a bit more detail.

 

The program I've written is a Producer/Consumer Loop which samples an analog waveform and exports it to a spreadsheet at discrete and triggered intervals. I've done this because I need better resolution that software timing can typically provide. So far so good, however, I would like to eventually append both a retriggerable elapsed time column (0-200ms for each sample) and a sample iteration column. Additionally--and a little further down the line--I would like to collect data on perhaps every other trigger event. I really only need to write a samply every now and again.

 

This would typically imply that I index each row of data and append the revised timestamp and sample iteration. I've attempted to use the Read from Spreadsheet VI to read into a for loop which appends the timestamp, but I feel as if this method is a bit superfluous. It seems I've run out of time for today, but if anyone has any bright ideas on how to accomplish any of these tasks I'll be up again tomorrow morning to take you up on it.

 

Thanks,

Travis

0 Kudos
Message 1 of 4
(3,770 Views)

Hey,

 

In this thread the issue is also covered. As GerdW says,

 

"You want to insert into the file, which means either:

- loading old data, convert to array, add new column, write to csv file (getting slower with each iteration)
- use buffering to hold all data in memory and write just once at the end of DAQ"

 

The best way to handle adding columns later is to use databases instead of spreadsheets, if that's a viable option. Otherwise you do have to read the data in, and then write it back out again after you edit it.

Britton C.
Senior Software Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,731 Views)

You should append rows instead. You can always transpose at the very end. Rows can be appended without touching the existing file content, while appending columns always means that the entire file needs to be rewritten (the existing content need to be shifted around and the column data interlaced).

0 Kudos
Message 3 of 4
(3,725 Views)
Solution
Accepted by topic author tdb867

Thanks you guys, I figured it out. I'll attach the code if anyone's interested.

0 Kudos
Message 4 of 4
(3,718 Views)