From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Write to Spreadsheet in columns

Hi folks! I am trying to write signals coming from a DAQ-Card into a file
and I would like perform
different measurements from the same signal and save it to the same file
but in different columns,
preserving the previous data. So far I managed only to append the new data
to the end of the column.
Thanks for any help!

Sergio Perillo
0 Kudos
Message 1 of 5
(4,637 Views)
Sergio Perillo wrote:

> Hi folks! I am trying to write signals coming from a DAQ-Card into a file
> and I would like perform
> different measurements from the same signal and save it to the same file
> but in different columns,
> preserving the previous data. So far I managed only to append the new data
> to the end of the column.

A little bit of experimentation with the Build Array node (and possibly
Transpose Array) might help solve this one. In order to get multiple columns
or multiple rows in your resulting tab-delimited text file, you will
definitely need to use the 2D array input of the Write to Spreadsheet File VI.

Given that, the trick is to make sure you actually create the desired 2D array
to input to the VI. If you've got a 1D array of data, and you do
some
measurements to create a resulting 1D array, the right thing to do is use the
Build Array node with the two 1D arrays as inputs to create (by default) a 2D
array. You would then transpose that array before feeding it into Write to
Spreadsheet File, assuming that you want your data in columns instead of rows.

Hope it helps,
John Lum
National Instruments
0 Kudos
Message 2 of 5
(4,637 Views)
John Lum wrote:

> Sergio Perillo wrote:
>
> > Hi folks! I am trying to write signals coming from a DAQ-Card into a file
> > and I would like perform
> > different measurements from the same signal and save it to the same file
> > but in different columns,
> > preserving the previous data. So far I managed only to append the new data
> > to the end of the column.
>
> A little bit of experimentation with the Build Array node (and possibly
> Transpose Array) might help solve this one. In order to get multiple columns
> or multiple rows in your resulting tab-delimited text file, you will
> definitely need to use the 2D array input of the Write to Spreadsheet File VI.
>
> Given that, the trick is to make sure you actually create the desired 2D array
> to input
to the VI. If you've got a 1D array of data, and you do some
> measurements to create a resulting 1D array, the right thing to do is use the
> Build Array node with the two 1D arrays as inputs to create (by default) a 2D
> array. You would then transpose that array before feeding it into Write to
> Spreadsheet File, assuming that you want your data in columns instead of rows.
>
> Hope it helps,
> John Lum
> National Instruments

Yeah, that's fine if you have all the data, but I think Sergio is trying to
append data periodically to an existing file. I'm pretty sure there's no way to
write to a file and append columns (there have been times when I would have liked
to do it myself, so I have thought about it).
But there should be a way to do it with ActiveX, no?

Rod
--
Roderic Don
Research Associate II
University of Delaware
Center for Composite Materials
302-831-8701
302-831-8525 (FAX)
0 Kudos
Message 3 of 5
(4,637 Views)
Roderic Don wrote:

> append data periodically to an existing file. I'm pretty sure there's no way to
> write to a file and append columns (there have been times when I would have liked
> to do it myself, so I have thought about it).
> But there should be a way to do it with ActiveX, no?

I'll assume we're talking about a data file (tab-delimited text) with more than one
row of data, because if you've only got one row, then it's pretty easy to add columns
by simply appending DATA to the end of the file using Write Characters to File.

In the case where you really do have a rectangular matrix of tab-delimited values
where each column represents a timeslice, then it will be pretty difficult to append
new columns of data without reading in the entire
file and doing some reformatting.
So, I'd advise transposing the way you store the data: use the columns to represent
data channels (or whatever the time-independent variable is). Then you can add a new
set of measurements by appending a new line to the existing file, where each line is
a tab-delimited set of measurement values terminated by an End of Line character.

--John
0 Kudos
Message 4 of 5
(4,637 Views)
Roderic Don wrote:
>John Lum wrote:>>> Sergio Perillo wrote:>>>> > Hi folks! I am trying to
write signals coming from a DAQ-Card into a file>> > and I would like perform>>
> different measurements from the same signal and save it to the same file>>
> but in different columns,>> > preserving the previous data. So far I managed
only to append the new data>> > to the end of the column.>>>> A little bit
of experimentation with the Build Array node (and possibly>> Transpose Array)
might help solve this one. In order to get multiple columns>> or multiple
rows in your resulting tab-delimited text file, you will>> definitely need
to use the 2D array input of the Write to Spreadsheet File VI.>>>> Given
that, the trick is to make sure you actually create the desired 2D array>>
to input to the VI. If you've got a 1D array of data, and you do some>>
measurements to create a resulting 1D array, the right thing to do is use
the>> Build Array node with the two 1D arrays as inputs to create (by default)
a 2D>> array. You would then transpose that array before feeding it into
Write to>> Spreadsheet File, assuming that you want your data in columns
instead of rows.>>>> Hope it helps,>> John Lum>> National Instruments>>Yeah,
that's fine if you have all the data, but I think Sergio is trying to>append
data periodically to an existing file. I'm pretty sure there's no way to>write
to a file and append columns (there have been times when I would have liked>to
do it myself, so I have thought about it).>But there should be a way to do
it with ActiveX, no?>>Rod>-->Roderic Don >Research Associate
II>University of Delaware>Center for Composite Materials>302-831-8701>302-831-8525
(FAX)>>

Hi Rod and John! You are absoluttely right Rod! John has sent me his help.
However It was not exactly the solution that I need. So I decided to gon
on this way and write a Matlab program to adjust the data in the arcquive(s).
But thanks anyway folks! Thank you very much!
0 Kudos
Message 5 of 5
(4,637 Views)