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: 

format into file help

creating a file.JPG

I am trying to break away from the "Write to measurement file.VI" and trying to learn to use the other File I/O VIs to customize my data.  Above is a simple VI I made to fool around with the settings of different File I/O VIs, though there are 2 things I can't seem to figure out how to make it do.

 

1) I need a way to break up the data into columns, so that instead of storing 1 long string into the A1 box, the B1, C1, etc boxes can be used.

2) I also need a way to break up the data into rows, so that I could eventually get something that looks like the following (assuming I threw in a for loop structure in the block diagram)

 

creating a file 2.JPG

0 Kudos
Message 1 of 6
(3,330 Views)

I applaud your desire to move away from the high-level Express VI type things, and stepping away from the drums long enough to do some LabVIEW.

 

Try Write To Spreadsheet File. It may be a VI, but look inside - it uses the lower level stuff - just arranged in a way to make doing what you want to do very easy. It even does "housekeeping" for you.

 

Write the "header" first, then in a loop, write your data, as this example demonstrate.

 

1.png

Richard






Message 2 of 6
(3,320 Views)

Or try editing the format string to format the data the way you want.  This outputs 3 dbls as *.CSV 

1.png

 


"Should be" isn't "Is" -Jay
Message 3 of 6
(3,309 Views)

OP: Jeff's response more directly answers your question, since your question was "format into file" help.

 

Personally, I've always found setting the file position to be an extra, unnecessary step since the functionality exists for free in Write To Spreadsheet File.

 

Pick your medicine! Smiley Happy

 

 

Richard






Message 4 of 6
(3,297 Views)

I've always found setting the file position to be an extra, unnecessary step since the functionality exists for free in Write To Spreadsheet File

 

1.png

Setting to end is easy enough.  With just 1 dtat type the write to spreadsheet file does offer some advantage.  But what about mixed data types? The write to spreadsheet then reqiers a bunch of scan from string - build arrays to convert the data.  

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 6
(3,284 Views)

@Jeff Bohrer wrote:

[...]

  But what about mixed data types? The write to spreadsheet then reqiers a bunch of scan from string - build arrays to convert the data.  

 


Granted. I could have probably saved a VI or two in the past by not using Write to Spreadsheet. It's all about choosing the right function for the job, and not just grabbing what you're comfortable with. In the OP's case, either solution is good.

Richard






Message 6 of 6
(3,279 Views)