LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write to file

Solved!
Go to solution

Attached is a picture of how I would like my data to look when I write it to a file.

 

Problems that I am having trouble working thru are:

 

1) writing different types of data to one file

2) writing two 4000 line arrays along with single lines of data

3) changing the headers for all of these

  

0 Kudos
Message 1 of 8
(3,508 Views)

Don't attempt to write different data types to one file.  Just convert everything to strings.  When viewing, they all look the same.

Writing 4000 lines is trivial if you use a For Loop.

Changing the headers is easy.  First write all the header information, then write the data.  Two separate steps.  Don't try to write them all at once. The top part of your picture does not have the same number of columns as the data part.  You can't create a 2D array with different number of columns.  So do it in two steps, header and then data.

 

In the future, convert your bmp file to a png.  It is smaller in size (much smaller).  Then just attach the png file.  No need to zip.

 

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 8
(3,494 Views)

tbob wrote:

 

Changing the headers is easy.  First write all the header information, then write the data.  Two separate steps.  Don't try to write them all at once. The top part of your picture does not have the same number of columns as the data part.  You can't create a 2D array with different number of columns.  So do it in two steps, header and then data.

 


 

 

 

Thanks Bob.

 

Unfortunately this has not been as easy as Bob mentioned. I am completely lost.

 

Can anyone direct me as to how I can do as Bob stated?

 

How do I write text to a spreadsheed with my text (headers) in the correct cells and text (data) in the correct columbs?

 

0 Kudos
Message 3 of 8
(3,440 Views)

You are using the Write to Measurement File Express VI, but you don't seem to have any actual timing data. Where is the data coming from? If you're just generating a 2D array of numbers you're better off just using the Write to Spreadsheet File. This will create a text file with delimited columns, like the Write to Measurement File Express VI, but you can easily call it twice to do as tbob indicated to write out the header first and then the data. 

Message 4 of 8
(3,418 Views)
Solution
Accepted by dpitcher

Here is an example of writing headers and data to a text file.

 

WriteFile.png

 

- tbob

Inventor of the WORM Global
Message 5 of 8
(3,398 Views)

I had to change the second "write data to file" vi to use double (instead of string) to get the data to save in columns and not rows.

 

Once I did that, it worked great.

 

 

Since I have only used the express vi "write meas file", the write-to-file portion of this project took WAY too long. But now I know a different way.

 

Thanks for the help.

0 Kudos
Message 6 of 8
(3,381 Views)

dpitcher wrote:

I had to change the second "write data to file" vi to use double (instead of string) to get the data to save in columns and not rows.

 


That statement makes no sense.  It doesn't matter if it is a 2D array of strings or a 2D array of numerics.  It will get written the same.  Also, a 2D array has rows and columns.  What do you mean when you say the data gets saved to columns and not rows. 

 

Is your data a 1D array or a 2D array.  If it is a 1D array, just wire it into the 1D input of the Write to File function, not the 2D input.  You probably wired the 1D numeric array to the 2D input.  Just move it to the 1D input.  Having the help screen open can give you lots of information you really need.  Use it.  You will see the separate 2d and 1D inputs on the Write function.  Using help would save you the trouble of having to post questions here.

 

You should not mix data types.  Your headers must be strings so you must convert your data to strings.  When you try to read back, you may have a problem if you mixed the data types you wrote.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 8
(3,365 Views)

tbob wrote:

dpitcher wrote:

I had to change the second "write data to file" vi to use double (instead of string) to get the data to save in columns and not rows.

 


That statement makes no sense.  It doesn't matter if it is a 2D array of strings or a 2D array of numerics.  It will get written the same.  Also, a 2D array has rows and columns.  What do you mean when you say the data gets saved to columns and not rows. 


It does for earlier versions of LabVIEW.With earlier versions of LabVIEW the Write to Spreadsheet File was not polymorphic, and only one instance existed.

Message 8 of 8
(3,360 Views)