LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting Data to Excel From While Loop

Hey Guys,

 

So I have a while Loop that is collecting data from a myRIO and running it through some formulas. There are 5 Analog voltage signals in all. What I would like to do is pass this data onto a spreadsheet in 6 columns. The first column being the time and the other 5 being the signals. What would be the best way to do this? Can I just build an array out of the 5 signals and the time and print that to a spreadsheet? I am pretty new to labview so thanks for your help.

 

Thanks!

0 Kudos
Message 1 of 11
(4,047 Views)

How fast do you want to write your data? For lots of data it is better to accumulate data in memory and write it to file once, rather than write to file many times.

 

Do you need an Excel file? Then you want to use the Report Generation Toolkit. If you just want a generic spreadsheet, then "Write Delimited Spreadsheet" should do.

 

Give it a try and if it doesn't do what you want, post your code here and explain what isn't working.

Message 2 of 11
(4,026 Views)

I can't get the program to write to spreadsheet vi to work. It is currently giving me an error number 7: it can't find the file. I would like the program to create the file each time and the user to name it and place it in a folder of their choosing. Can I use the create file function with the write to spreadsheet function? 

 

I can't upload the vi. Or a picture because it is on a secured network. 

Thanks for the help!

0 Kudos
Message 3 of 11
(4,007 Views)

Ideally it would be able to record at 100hz. Currently the write to spreadsheet file is inside the while loop.

0 Kudos
Message 4 of 11
(4,006 Views)

100Hz is pretty fast to write to a file, I would put it after your loop and see if that works.

 

Error 7 sounds like you are not feeding it a valid path.

 

You can use the File Dialog Express VI to prompt the user to pick a path for the file. Without seeing any code, I can't offer any more help than that.

0 Kudos
Message 5 of 11
(3,987 Views)

Here is my code. Its very messy still but what you need to know is: the part in the decorative box will not write to spreadsheet file. It gives me the No File Found error. I want it to create one not just write to one. 

 

Also will the time stamp print out as a tangible number? I converted it to a double then 1d array but I don't know if this will print to excel as a knowable number.

 

Also it doesn't necessarily have to be an excel file, it could be a csv file. I would like to learn how to do both.

0 Kudos
Message 6 of 11
(3,963 Views)

Write Delimited Spreadsheet does a pretty good job!  I "did an experiment" -- I ran a For loop 500 times at 100 Hz.  Within each loop, I generated 100 random Dbls and wrote them to a Delimited Spreadsheet (as rows).  If I tried to do 1000 rows, it gave some weird error at the end, but 500 row it did just fine.

 

But how many columns?  I almost didn't check -- oops, short, only 94.  That's weird.  So I started slowing things down and shortening the loops.  It depends on the Row length, not the speed, number of rows, etc.  At 10 Hz (10 times slower!), it does 15 columns just fine, but can't do 20.  If I ask it to do 15 columns at 100 Hz for 1000 rows, it, again, does just fine.

 

This was run on my laptop (2 years old, Windows 10 x64, LabVIEW 2016 32-bit.  Keep those rows short, and Write Delimited Spreadsheet might do the trick.

 

Bob Schor

 

P.S. -- Remember a Former Governor of California -- "Trust, but Verify".  Write a little "Generate and Test" routine for yourself.

0 Kudos
Message 7 of 11
(3,961 Views)

Hi Mike,

 

I don't see any file writing functions in your code, did you upload the correct file?

0 Kudos
Message 8 of 11
(3,960 Views)

Hi! I suggest you to read these two articles, they explain how to create a spreadsheet and how to pass the data to an Excel file!

 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P8nqSAC

http://www.ni.com/newsletter/51339/en/

0 Kudos
Message 9 of 11
(3,933 Views)

@MikeIsMyName wrote:

Here is my code. Its very messy still but what you need to know is: the part in the decorative box will not write to spreadsheet file.  I did not find the "decorative box", nor any place to write to a spreadsheet file.  I assumed that was going to go in the lower Consumer loop.

Also it doesn't necessarily have to be an excel file, it could be a csv file. I would like to learn how to do both.  There are examples for writing to Excel using the Report Generation Toolkit.  There may also be some for the Write Delimited Spreadsheet, but if you put this function down on an empty Block Diagram and look at its Help description, you can probably figure it out for yourself.  Make up some data and just try it.


Bob Schor
0 Kudos
Message 10 of 11
(3,922 Views)