LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save data from multiple arrays into one file using "Write Delimited Spreadsheet.vi"?

Solved!
Go to solution

Hello dear LabVIEW community.

 

I'm wondering if somebody can help me with writing several arrays into one file please (without the use of report generation toolkit).

 

This question builds upon my other question, which Bob Schor - thank you so very much to him - helped me to resolve.

 

I'm obtaining voltages from 4 sensors with "DAQmx read.vi". Then, I split the data into 4 arrays with "Index array function".

 

My goal is to save the data from the 4 arrays (arrays represent the 4 sensors). I prefer the data to be saved in one file Excel can read, where each column corresponds to a sensor and has a header with the sensor's name.

 

Note, that even though I said "I prefer", I really just want to save the data in a way I can read it with Python afterwards (separate .txt files, one .txt files, separate or combined delimited spreadsheets - any will work for me). In other words, if it is difficult to meet my preference, anything will do (except for TDMS and binary).

 

To achieve my goal I tried a variety of ways. The last one - the most promising one which is used in the attached .vi - combines the 4 arrays into one array using "Build array function". The output of "Build array function" is then fed to the "Write Delimited Spreadsheet.vi".

 

When I run the program and try to save the data, I get a raw of 4 zeros in the file. I don't know how to resolve that issue.

 

I probe every array with a waveform and can see non-zero signals fluctuating in time above zero for each array.

 

The specs are as follows.

  • LabVIEW version 21.0
  • DAQ board is NI USB-6009
  • Computer is HP Z220, Intel Xeon, CPU E3-1240 V2 @ 340GHz, RAM 12GB, 64bit operating system, x64 based processor
  • Windows 10 enterprise, version 20H2, OS build 19042.928, Windows feature experience pack 120.2212.551.0
  • .vi with my program is attached
  • Troubleshooting steps attempted:
    • tried to change "continuous" acquisition mode to "N samples" -> the program wouldn't run at all and would give me some error
    • tried to feed each of the 4 arrays to its own delimiter spreadsheet, thus, having 4 delimiter spreadsheets outside the "while" loop -> I would get only one non-zero value in each spreadsheet where I expect to get a lot more values because I set the task to acquire 1000 samples at 1000Hz
    • I tried this thing -> array wouldn't get wired to the "write to file function"
    • I also read about "Report generation toolkit" -> it's going to be paid soon and we aren't buying it
    • I've been searching all over the forum and the Internet, but have failed to find a solution

Thank you in advance.

Ivan

 

 

0 Kudos
Message 1 of 3
(863 Views)
Solution
Accepted by topic author nepomnyi

Hi.  This "Bob" guy probably gave you "incomplete" advice.  Here are a few tips:

  • Write Delimited Spreadsheet expects a 2D Array of (numeric) data, with the Rows being "Channels" of data and the Columns being "Samples".
  • Actually, that first statement isn't 100% accurate, but we'll leave that for another day.
  • The Write Delimited Spreadsheet has the neat behavior that you can do multiple writes and append new data to the end of the data that came before.  This is especially useful when you are looping, generating N-Channel N-Samples over and over -- you simply write 1 2D array after another.  The Write Delimited Spreadsheet automatically closes the file for you after you write it, and there's an "Append File" input (which you've wired as "False", but which you want to be "False" only for the first Write, and True every write after that.  Do you know how to do this?  Does the term "Shift Register" help"?  What if I said to write a False before you enter the loop, and wire a "True to the "inside" of the Shift Register on the right-hand edge of the loop?
  • You chose to output your data as a 1D Waveform.  So you'd need to convert it from Waveform to 2D Dbl.  You could also directly output it as 2D Dbl, but then you need to think about if you need to transpose the data.  Fortunately, you can "try it", and if you need to Transpose, the Write Delimited Function will do that for you!

So spend a little more time with the Help function for Write Delimited Spreadsheet, learn what an "Array Wire" looks like, learn what a "Cluster" or "Waveform" wire looks like, and know the difference.  Whoever this Bob guy is can't do everything, though I suspect he (or maybe she, you never know these days) is trying to teach you something about LabVIEW and how to learn it ...

 

Anonymous

Message 2 of 3
(836 Views)

Thank you very much again, Bob!

I have solved the problem. Even though, it doesn't seem like I used all of your suggestions. Thus, I couldn't make use of the "Append file" option.

My problem was that I didn't use shift registers.

In one run of the while loop, I acquire 1000 samples. I have to store them. Shift register stores them for me.

In the next run, I acquire 1000 more samples and have to add to the ones I had stored before. For that purpose, I use the function "Index array function". 

And so on.

Once the while loop is stopped, the data gets transferred to the delimited spreadsheet.

That's how my .vi works and it is attached to the current post.

Ivan

P.S. I didn't manage to create headers for each column in the delimited spreadsheet. And I, already, don't want to mess with it. I'm leaving it as is.

0 Kudos
Message 3 of 3
(797 Views)