Jump to content

Writing from 2D-array to file


Recommended Posts

Hey! I am pretty new to LabVIEW, and have just encountered a problem I am looking for a simple solution to.

 

I am collecting samples from two channels on a NI-DAQ-Device. The DAQmx Read-VI outputs a 2D array, where each row represents one channel. I want to write this data to a file in the following format:

 

sample 1 from ch1; sample 1 from ch2

sample 2 from ch1; sample 2 from ch2

etc; etc

 

Is there an easy way to do this? Thanks!

Link to comment
You could use the Write To Spreadsheet File.

Just be careful with this vi, because it doesn't have an error out.

If you're passing it an invalid file path or it can't write to the file for some reason, it will pop up an error message blocking everything else, unless you've got automatic error handling disabled, in which case you will never know that things go wrong until you can't find the files.

 

This is why I sometimes prefer to use a combination of "Array to Spreadsheet String" and "Write to Text File", which allows you to handle the errors.

Edited by ThomasGutzler
Link to comment
Just be careful with this vi, because it doesn't have an error out.

So whenever I go to use this function for simple programs, I always open the VI copy away the functions it calls (which admittedly aren't much) and paste those into my VI instead of calling that VI directly for that reason.  Wouldn't it suck if all VIs on the palette didn't return an error but instead had a simple error handler in each of them?  Then why do that for this function?

Link to comment

Just be careful with this vi, because it doesn't have an error out.

If you're passing it an invalid file path or it can't write to the file for some reason, it will pop up an error message blocking everything else, unless you've got automatic error handling disabled, in which case you will never know that things go wrong until you can't find the files.

 

This is why I sometimes prefer to use a combination of "Array to Spreadsheet String" and "Write to Text File", which allows you to handle the errors.

 

 

The Robust CSV package from the Code Repository includes error handling and can handle strings containing commas and cr/lf

 

http://lavag.org/files/file/239-robust-csv/

 

Finally, something that can manage crlf:P

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.