LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading multiple csv file to Waveform graph

Solved!
Go to solution

Hello There, I have been asking for help in Labview forum for a while since I am a new user. I am trying to build an application where you can filter our your desired csv file(2 variable or 3 variable data sheet) from a directory and open them in Waveform graph. I have figured out all part except the last one where I can display the data sheets into graph. I know that i have to use 'Read delimited Spreadsheet' element but I am still having hard time figuring out connecting elements with each other. If you run the attached snippet. you will see I can filter out my desired files (Which are also attached here) into 'selected file' box from 'file box' list. What I want to do is directly import the csv files from 'selected file' box to graph. If anyone have suggestions,please let me know. Thank you. Multicolumn list box v1.2.png

0 Kudos
Message 1 of 21
(5,772 Views)

Below is a snippet reworking your VI a little. Your loop had no wait, so it was running as fast as the computer could manage - I added an event structure to prevent this. Now, it does something only when you change something.

 

The handling of the files should be similar, except you should now press Done when you've selected all of the files you want - they will display each time you change your selection. The Done button should trigger the reading of the files in my snippet. I show it below with the Done case visible, which shows building the paths you need. I'm not sure what exactly you want to do with the multiple sets of data and so on (since both Files and Selected Files allow more than one selection).

 

Example_VI_BD.png


GCentral
0 Kudos
Message 2 of 21
(5,727 Views)

First of all, Thank you very much for enhancing my application. What i wanted to do is, the csv files that I have put in the 'selected files' box by selecting, i wanted them to open up in waveform graph. I wanted to have more than one csv files opening up in graphical format in the same plot. This is for comparison purpose. 

0 Kudos
Message 3 of 21
(5,710 Views)

Following the previous comment, here is the update of my application. If you run it, you will see basically I am trying to plot the csv file from the active file box into XY graph. If you can help me to get this , then that would be great. Thank you. Multicolumn List Box V1.4.png

0 Kudos
Message 4 of 21
(5,703 Views)

Hello Everyone,

this is the latest version of the my application. I have attached the block diagram snippet here. If you run it, you will see you can filter out you preferred csv files into 'Active file' box by double clicking on the files from the 1st box once it loads there from directory. What I am trying to do is, I want to read more than one csv files from the 'Active file' box and plot the data sets all in one XY graph. I want to have multiple csv data sets in one XY plot because I want to compare the plots. If anyone can help me out or make suggestion, that would be great. if anyone can show me an appropriate discussion link, that would be also appreciated. Thank you. Multicolumn List Box V1.4.png

0 Kudos
Message 5 of 21
(5,741 Views)

Hi Huqs,

 

read those "Active Files" in a loop. With each iteration you read one file and create your plots from it. At the loop border you create an array of plots, either with simple autoindexing (one plot per file) or by concatenation mode (several plots per file)…

 

What have you tried so far? I created this in 2mins:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 21
(5,735 Views)

See I did not try much yet. I am actually a relatively new use. So far I have tried to connect the active file value property to read delimited spreadsheet and from there I was planning to separate X and Y values and bundle them to connect in XY graph element. But it's not quite working out. However, what you suggested, I will try to do that. 

0 Kudos
Message 7 of 21
(5,727 Views)

GerdW,

i wasn't able to open and run the snippet you attached since I am running Labview 2015 and yours was made in 2016 version

0 Kudos
Message 8 of 21
(5,725 Views)

GerdW,

So I tried what you suggested, but I wasn't working. So I tried this. But it wasn't working either. I don't know where things are going wrong. Multicolumn List box V 1.5.png

0 Kudos
Message 9 of 21
(5,711 Views)

It's finally working! But it's not showing all the plots from the active files box. I have attached 2 specific csv file. it's just showing the 1st one and not the 2nd one. IDK why, although the 2nd one does load in. I have to see how can I modify graph display to show them altogether. Multicolumn List box V 1.5.png

0 Kudos
Message 10 of 21
(5,708 Views)
Solution
Accepted by topic author Huqs

I'm guessing this is what you want. If you don't want to use the first column as X and the second as Y, make some minor changes to the Files: Double Click case.

 

The code uses the Read From Delimited Spreadsheet with a comma set as the delimiter and reads only the first two columns, since it doesn't look like you're using any others (again, you can change this).

 

Then it uses Index Array, with the row input unwired and the column wired with 0 and 1 to get 1D arrays of the columns. It bundles those together to form what the XY-Graph considers a "plot" (copied from detailed help):

The XY graph accepts three data types for displaying multiple plots. The XY graph accepts an array of plots, where a plot is a cluster that contains an x array and a y array.

This is then passed to a Build Array node, which adds it to existing data. To remove the plot in the Active Files: Double Click case, just use delete from array in the same way you already did.

 

The other cases have the wire passed through. I deleted Timeout since you weren't ever going to see it (no timeout constant).

 


GCentral
Message 11 of 21
(1,693 Views)

Hi Huqs,

 

It's finally working! But it's not showing all the plots from the active files box.

No, it's not working as intended!

 

THINK DATAFLOW!

In your snippet you are loading ONE (1) file and display just ONE (1) plot from its data.

THINK DATAFLOW!

 

In my snippet I told you to load an array of files and to create an array of plots, using a loop.

It seems you missed this completely!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 21
(1,679 Views)

Hello cbutcher, 

Yes, this is exactly what I was looking for! Thank you very much for the file and all the explanation. I attached two different csv files earlier and I tried to open both of them at the same time. But it only opened the 2nd one. So, I will look into why it's not opening both at the same time. Maybe make some minor changes. You obviously saw that we can double click and remove files from the 'Active file' box. My next goal is to remove the plot of a dataset by just double clicking it's csv file in the 'Active file' box and removing it. 

0 Kudos
Message 13 of 21
(1,680 Views)

Oh wait, nevermind. You already added the removal of graphs via 'active file' box already. 

0 Kudos
Message 14 of 21
(1,675 Views)

Great. So it does what you want, right? I tried to get the idea of what your goals were from the VI you provided - any changes should hopefully be fairly simple for you to make for minor changes.


GCentral
Message 15 of 21
(1,670 Views)

Hi Huqs,

 

it would be nice of you when you would not ask the same question in several threads the next time (aka no double posting please)!

 

I merged your threads…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 16 of 21
(1,672 Views)

Ah - that's why I was so confused reading through this thread that I thought I'd replied to but didn't recognise half of!


GCentral
0 Kudos
Message 17 of 21
(1,669 Views)

Hi GerdW, 

I am sorry for that. It won't happen again. 

0 Kudos
Message 18 of 21
(1,661 Views)

can u plz tell me which function is that after read function

0 Kudos
Message 19 of 21
(1,286 Views)

Hi Om,

 

did you use the context help? It will tell you the name of the function…

 

Spoiler
(IndexArray, atleast in the VI marked as solution.)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 20 of 21
(1,283 Views)

@Om2404 wrote:

can u plz tell me which function is that after read function


A plea for full words

0 Kudos
Message 21 of 21
(393 Views)