LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i create a graph from an excel file?

I have an excel file(100000 rows and 2 columns) of data from an oscilloscope. I want to plot a signal from the data in this file. Most of the videos on the internet describe how to save data to excel files. Is there anyone who can help me? I attached excel file if you need.

0 Kudos
Message 1 of 7
(3,606 Views)

So since you have a real Excel file (rather than a .csv or similar file), your best bet is likely to try using the Report Generation Toolkit to open and read the file.

There's an example program here: Reading Excel Data Programmatically Using the Report Generation Toolkit 

 

If you can instead use a CSV file, you'd have an easier time with the use of simple VIs/nodes like Read Delimited Spreadsheet VI or Read Text File and Spreadsheet String to Array.


GCentral
Message 2 of 7
(3,587 Views)

I read the first solution. The Report Generation Toolkit example you gave had subvi's and it seemed very complicated to me. I converted my .xlsx file to a .csv file. I couldn't make any connection to the solutions you proposed for this. I don't know how to use these tools. Related videos are insufficient. I've read and tried all of the links you've sent, but it doesn't seem understandable to me. 

Can you show me a simple example with these tools and my file for plotting a signal wave in graph indicator?

Thanks for your helps.

0 Kudos
Message 3 of 7
(3,549 Views)

You failed to post your VI, so we have no idea what you tried, and can't suggest how you can fix it.  I can say, however, that your CSV "copy" looks nothing like your Excel Data File, so it would be useless to suggest how you could read (the data are garbage!).  The other thing that looking at your code would tell us is which Version of LabVIEW (or LabVIEW NXG) you were using ...

 

The "trick" to using the RGT to read Excel is to realize that when you Create Report and connect an existing Excel File to the "Template" input, it becomes available for reading. Fortunately for you, the entire XLSX file is two columns of numeric data (no headers).

 

You only need three Functions to accomplish your goal -- Create Report (with the XLSX file wired into the Template Input), Excel Get Data (with a 2D Array of Dbl wired in to the Data Type input, and an Indicator wired into the Data output, and Dispose Report.  When you run it, Excel will open, read the XLSX, close, and all of your data will be in the array "Data".

 

Bob Schor

 

P.S. -- if this works for you as well as it worked for me, consider clicking the Solution button, which I think is on the lower right of this Reply.

 

P.P.S. -- I realized I only answered the "How do I get the data from Excel into LabVIEW".  I'm assuming that once you have the 2D array (of X and Y), you know how to Chart or Graph it.  

Message 4 of 7
(3,479 Views)

Hi, first of all, data are inconsistent (columns have different lenghts) so the result can't be good as expected...

 

If you want to better understand labview connectivity functions, please consider to use ActiveX technology instead of NI MS office report generator.
attached you can find an example to read data from a rectangular range of an excel sheet displaying data on a graph.

Enjoy!

0 Kudos
Message 5 of 7
(2,113 Views)

@Max71 makes a good point -- I didn't really look at your attached .xlsx file (thank you for attaching it!).  The first Column contains the numbers 1 .. 805 (and stops at Row 805), whereas the second Column seems to contain "real data" and stops at Row 100000.  I'm not sure how you generated this strange file format, but apparently after you'd written less than 1% of the file, you realized you didn't need Column A, and just stopped writing it.

 

So what do you do if you want to use the RGT?  In my earlier Reply (#4), I explained you could do this with three RGT functions.  I had not actually tried it with your data, but when I did (just now), I got a 2D Array of Dbl (which is what I asked for) of size 100000 x 2.  Of course, most of the first column (except for the first 805 values) was 0, but you can always "throw it away later".

 

[Just as a fun exercise, I added a tiny bit of code to make the Read function just read Column B.  I still got the requested 2D Array, but now it was 100000 x 1, and had just the Column B data.]

 

For simple things, I prefer the RGT and not thinking about ActiveX, but I'm a little lazy ...

 

Bob Schor

 

0 Kudos
Message 6 of 7
(2,094 Views)

@Bob: You are not lazy, you are just using what NI suggest to use and it's fine, the final result is the same.

I suggested ActiveX instead of RGT because I'm using that technology since 20 years, before RGT creation (from this point of view I am lazier than you), because I prefer to control every single point of my software and because once learned ActiveX (or .net) approach, it's possible to communicate also with other applications.

 

Happy new Year

 

0 Kudos
Message 7 of 7
(2,076 Views)