LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to write column data with headers to a file

Hi all

I want my vi to search an existing file and append data to the right of the existing column along with the header.  I could write data to different columns but not with the header. The header is written only once and subsequent new data is appended without a header.  I've attached my code. Does anyone know how to do this?

 

Thanks 

Download All
0 Kudos
Message 1 of 7
(3,921 Views)

See code screenshot incase for older labview versions

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

@SolPS wrote:

Hi all

I want my vi to search an existing file and append data to the right of the existing column along with the header.  I could write data to different columns but not with the header. The header is written only once and subsequent new data is appended without a header.  I've attached my code. Does anyone know how to do this?

 

Thanks 


If you have the Report Generation Toolkit, this is almost trivial.  You can open an existing Worksheet, determine the number of rows and columns present, then start adding new columns to the right of the existing columns, with a header if desired.  When the new columns have been added, the Excel file can be saved (with the same or a new name) and Excel closed.

I suppose you could do the same thing with the Delimited Worksheet functions.  Read the data as strings (to get sizes).  I've not used these functions enough to know if writing Dbl arrays preserve the precision of the original data or not, but you could experiment.  Now you need to "expand" the data array by adding another column, then do the appropriate (expanded) Write Delimited Spreadsheet.

 

It's a little messy, but you might be able to cobble together what you need using one of these methods.  Give it a try.

 

Bob Schor

0 Kudos
Message 3 of 7
(3,875 Views)

Hi Bob_Schor,

 

I decided to follow your advice and use excel functions from the report generation toolkit. I've created a VI to do that but I still can't get it work. It still inserts data into the same position deleting the initial data.  See attached code and screenshot.

Download All
0 Kudos
Message 4 of 7
(3,820 Views)

Seems like you are over complicating this.

 

Simply write your column headers as strings to your data file ONCE and BEFORE you enter a loop to write your numerical data.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 7
(3,814 Views)

RTSLVU,

I don't understand what you meant by writing the column headers once before entering the loop. The data input to the excel easy table function is a required input and if it's not wired, you'll have a broken VI. Can you explain a bit more or modify the VI I attached?

0 Kudos
Message 6 of 7
(3,804 Views)

@SolPS wrote:

RTSLVU,

I don't understand what you meant by writing the column headers once before entering the loop. The data input to the excel easy table function is a required input and if it's not wired, you'll have a broken VI. Can you explain a bit more or modify the VI I attached?


Okay... Well to start off I don't use the Excel Easy Table, I find it beast to just save my data as a Tab delemited text file, then Excel can read it fine and you can look at it with any text editor.

 

Bear with me here as this may not be the best example but... Here after I setup my DC source I write my column headers to the data file that the user selects when the dialog pops up.

Headers.PNG

 

Then I write my data a row at a time as it's taken.

write.PNG

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 7
(3,799 Views)