LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build Array and Output Values to Text or Excel File

I know this is a simple question but I need some help. I'm reading a DC voltage in LabVIEW a while loop. I want to store all the read values into an array and export that array as an text or Excel file. I had a VI that I build before for this but I cannot seem to find it and I can't remember how I did it before. Any help is appreciated. I think I can do the exporting part but I do help with building the array (storing all the data values).

0 Kudos
Message 1 of 17
(6,011 Views)

There is a function under the File I/O called "Array to spreadsheet file". Give that a try.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 17
(6,004 Views)

I couldn't find "Array to spreadsheet file" but I did find "Array to spreadsheet string".. Is this what you were talking about?

 

I actually need more help building the array. I attached a screenshot of what I'm working on. I think I can use the "Write to Measurement File" express VI to write the file once I have the array.

0 Kudos
Message 3 of 17
(5,994 Views)

I wouldn't recommend building an array of all of your data then doing a single file write.  Since you are using a while loop, I assume you don't know how long the loop is running for so you (or LabVIEW) won't know how much memory to allocate.  It lends poor performance because of continuous memory allocations and you could also run out of memory.

 

It is much better to stream your data to disk as you go (assuming you are running for longer periods of time).  Check out some of the File IO Examples in the example finder.

 

Browse>>Fundamentals>>File Input and Output>>Write to Text File.vi

Lewis Gear CLA
LabVIEW UAV

Message 4 of 17
(5,986 Views)

Thank you for the tips. In this case I am using a while loop but I will actually change my code in the future and use a for loop. I only have take about 100 measurements or so. I will look into the example VI.

0 Kudos
Message 5 of 17
(5,982 Views)

If it is such a low number of measurements the auto-indexing on the loop will build an array for you and then you could use the Write To Spreadsheet File VI 

Lewis Gear CLA
LabVIEW UAV

Message 6 of 17
(5,976 Views)

I know this is a stupid question but I couldn't get the auto indexing to work with my while/for loop. Can you post an example, if you have one? That's what I been stuck on actually. I saw some examples online and those worked in terms of building the array but when I tried to re-create the VI my VI wouldn't create the array. I accidently deleted the VI's or else I would post them.

0 Kudos
Message 7 of 17
(5,973 Views)
0 Kudos
Message 8 of 17
(5,970 Views)

Thanks. I don't know why it didn't work before; I did have the auto indexing on. But I just created one of the example VI's I saw before it worked, :). And also it's working in my code. Thank you for the help.

0 Kudos
Message 9 of 17
(5,966 Views)

I run into a problem while using the "Write to Text File Function". Initially I took about 60 measurements and wrote to a text file. That works but I increased the amount of measurements to be taken to 600 and when I did that the output in the text file are all Chinese letters (or that's what it seems like). Is this because I'm writing too much data?

 

When I use the "Write To Spreadsheet File VI" to write the measurments it works fine for the 600 measurements. The problem with this is I cannot insert any text. Using the "Write to Text File Function" I inserted some text before the measurements and "end of lines", to format the data. Attached is a screenshot of my VI.

 

 

0 Kudos
Message 10 of 17
(5,928 Views)