LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simple way to save array cluster for file

Solved!
Go to solution

Hi,

 

I have a array cluster from I used to plot to and XY graph that I now wish to save to file. What would best way to save it  (as a txt or csv) in a save as dialog style ie user prompted to enter filename before saving?

0 Kudos
Message 1 of 14
(4,618 Views)

I prefer XML.

ex.png

 

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 2 of 14
(4,585 Views)

If you are plotting a graph, then you probably have X-Y pairs.  I would think that it would be easy to convert the array of clusters to a 2D array of Dbls.  Hmm, I thought I remembered an Array to Spreadsheet and Spreadsheet to Array set of functions (in addition to Read/Write Delimited Spreadsheet File), but maybe they were dropped 4-5 years ago since I never used them ...  But there are still Read/Write Delimited Spreadsheet File that can read/write .csv files (you need to specify the comma as a delimiter, unless you prefer the default value of <tab>).

 

I agree that XML can be nice, but it has its own idiosynchrasies ..

 

Bob Schor

0 Kudos
Message 3 of 14
(4,581 Views)

@paul_cardinale wrote:

I prefer XML.

ex.png

 


With results almost as cryptic as the xml produced, you could flatten to string and save it to config file!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 14
(4,575 Views)

Hi,

 

I've been trying some stuff and for now the most convenient way for me is/was to use the invoke node ExporttoExcel as I get the plot data as displayed instead of just the cluster array. 

 

However what is inconvenient is that 

1. PC need excel (not exactly a prob! 🙂 )

2. User need to explicitly do Save as 

 

Ideally what I would want to achieve is

ExporttoExcel invoke node - > SaveAs Dialog -> user enters filename -> file saved as csv

 

OR

 

ExporttoClipboard invoke node ->Save As Dialog -> user enters filename -> csv file created ->data pasted into file by labview before close

 

Are either achievable?

 

 

0 Kudos
Message 5 of 14
(4,567 Views)

Hi,

If you want to save array data to excel, the easiest way would be to use one of LabVIEW's 'write data to' functions. As you already have array data, this will be the simplest solution to your problem.  

If your issue is related to avoiding the report generation toolkit. There is a support page that explains how to use the write data to excel functions without a report generation toolkit here.

 

Regarding your question on whether you can use the export to clipboard or excel invoke nodes, it is possible to do so using the export to clipboard invoke node. As you can see in the code below, you can access your clipboard data after using the Export to Clipboard Invoke node, but you would then still need to use one of the functions mentioned above to save the data to file.

forum thing.PNG

As you had access to this array of data on the block diagram already, this process is a little redundant. I would suggest to just simply use the write to data function right from the beginning.

Message 6 of 14
(4,555 Views)

unfortunately that does not work for me (unless I'm doing it wrong!)

I have multiply xy plots and using "ExporttoExcel invoke node" or "ExporttoClipboard" (and paste in excel) invoke nodes I get a neatly speadsheet with each plot on seperate columns. Here what I would like more is the user prompt to save the file...

 

With the cluster of array I tried using a for loop to go through each element, unbundled it into a 2D array and added it file using the "Write delimited Spreadsheet VI" but ended up with only 2 columns (ie all plots were added onto came colunms) ! How do I add columns to my file?

 

0 Kudos
Message 7 of 14
(4,533 Views)

You know the structure of your data, you know what you would like for the appearance of the file, and you have some code that does "the wrong thing".  We can guess what you want, but you have the ability to show us by attaching your code (no pictures, please, just VIs), perhaps attaching some data, and/or attaching a text file that you create (perhaps with NotePad) that is an example of what you hope to achieve.

 

I understand that you are talking about multi-line plots.  Are these Charts (i.e. only the Y value is really important) or X-Y Graphs?  If you are talking about multiple lines-on-a-plot, do you want the points arranged as Rows or as Columns?  Do you want a Header Column/Row (e.g. Plot 1, X / Plot 1, Y / Plot 2, X / Plot 2, Y)?  What if you have multiple plots?  Each one gets its own File?  You put them all on the same file with another Header (Plot 1, Plot 2, etc.) to separate them?

 

Before starting a LabVIEW (or any programming) task, it is a good idea to plan what you want to do in sufficient detail that when you get stuck on how to do it, you can provide a clear idea of the "what", almost always more important than the "how".  So much for philosophy ...

 

Bob Schor

0 Kudos
Message 8 of 14
(4,526 Views)

@Bob_Schor wrote:

You know the structure of your data, you know what you would like for the appearance of the file, and you have some code that does "the wrong thing".  We can guess what you want, but you have the ability to show us by attaching your code (no pictures, please, just VIs), perhaps attaching some data, and/or attaching a text file that you create (perhaps with NotePad) that is an example of what you hope to achieve.

 

I understand that you are talking about multi-line plots.  Are these Charts (i.e. only the Y value is really important) or X-Y Graphs?  If you are talking about multiple lines-on-a-plot, do you want the points arranged as Rows or as Columns?  Do you want a Header Column/Row (e.g. Plot 1, X / Plot 1, Y / Plot 2, X / Plot 2, Y)?  What if you have multiple plots?  Each one gets its own File?  You put them all on the same file with another Header (Plot 1, Plot 2, etc.) to separate them?

 

Before starting a LabVIEW (or any programming) task, it is a good idea to plan what you want to do in sufficient detail that when you get stuck on how to do it, you can provide a clear idea of the "what", almost always more important than the "how".  So much for philosophy ...

 

Bob Schor


Was expecting for someone to comment like that! 😉

 

I do not have some code that does the wrong thing so to speak... been iterating through possibilities with no success... so really building on the fly...

 

However to answer you other comment:

What I am constructing is a VI where the user construct plots that is then added to an XY plot (used as preview here). those constructed waveforms will then be used to control an NI-DAC.

 

The way I have done it so far is that once the constructed plots are added to the XY plot they are adjusted so ALL have the same X width (so yes, they can then be considered as charts at that point).

 

the last step which I am struggling with so far is saving the XY plots to a file so that it may be recalled. Ideally I would like all in one file. if not .csv then TDMS will do but just do not know how to transfer ALL the plots (with headers) to file. Please help

 

 

 

0 Kudos
Message 9 of 14
(4,513 Views)

hi sherzaad,

doesn't sound too complicated,

your logic already converts/adjusts the data,

which means you only have to write this data to something.

 

have a look at "Write Delimited Spreadsheet.vi" for CSV,

or for TDMS search in the examples coming with labview (e.g. "TDMS Write Events Data.vi").

read up on TDMS http://www.ni.com/tutorial/9334/en/

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 10 of 14
(4,504 Views)