LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble getting array from Excel file

Solved!
Go to solution

This will likely be a very stupid question, but is there anything I could be doing wrong when trying to get a 2D array from an Excel file? The file contains two columns of data which I want as a 2D array (or two 1D arrays) and having tried a couple of things I'm not getting anything up on my graph. The VI attached is a work in progress and has been hashed together from some other work (it will be used to control scanning mirrors).

 

 

Thanks in advance,

 

 

Ben

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

Are you trying to read an actual Excel file ( .xls ) or a delimeted/spreadsheet text file?

0 Kudos
Message 2 of 7
(3,190 Views)

Hi Ben,

 

Could you please post the actual file that you are trying to read from or a representative one if that is not possible. Also could you send the actual file I/O code you are working on, which has been cut back to only the file I/O part. This will allow me to run the code and see your exact problem. I will then be able to advise on how to overcome the problem.

 

Best Regards,

 

Christian Hartshorne

NIUK

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

The file is saved as a .csv file, I've tried saving it as a .xls but it hasn't made any difference. The file is generated using a fairly simple python code, with an example attached. I realise I'm probably missing something very obvious, so thank you for being patient!

 

 

Ben

0 Kudos
Message 4 of 7
(3,148 Views)

Your file is a CSV comma separated file.  The Read from Spreadsheet File has a default delimiter of a tab.

 

Wire a string constant with a comma into the delimiter input of the Read from Spreadsheet File and it will handle your CSV file correctly.

Message 5 of 7
(3,123 Views)
Solution
Accepted by topic author bencarrick

Hi Ben,

 

I have found a Knowledge Base article which relates to your exact problem. I have linked this below.

 

Reading Microsof Excel Numeric Data into LabVIEW

 

Having followed the steps in the KB, I changed the file to a text (.txt) file and was then able to read the data successfully and plot it on the XY Graph using a modified version of your code that only contains the File I/O element. If you make the necessary changes to your data file and then reference it in the modified VI that I have attached, this will illustrate how you can read your data into LV.

 

I hope this helps.

 

Best Regards,

 

Christian Hartshorne

NIUK

Reading Microsoft Excel Numeric Data Into LabVIEW

0 Kudos
Message 6 of 7
(3,077 Views)

Thank you, changing the file type solved the problem!

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