LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read an excel file and convert to a 1-D array of long, 32-bit integer?

My vi right now reads an column of numbers as a 1-D array, but I need to input the numbers manually, and for what I'm trying to do, there could be anywhere between 100 to 500 numbers to input. I want the vi to be able to read the excel file and use that column of numbers for the rest, which the data type is long (32-bit integer).

 

I have an example vi that is able to get excel values, but the output data type is double (64-bit real).

 

I need to either be able to convert double(64-bit real) data to long (32-bit integer), or find another way to get the values from the excel file.

0 Kudos
Message 1 of 20
(3,783 Views)

Can you share your example?  It might be something as simple as telling it to output an I32.  Or you can simply use the I32 conversion bullet (look in the numeric->conversion palette).



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 20
(3,782 Views)

Attached is the example. If that isn't enough, I can provide the vi with which I am trying to have it work with.

 

I have looked through a conversion palettes, but it's very possible I skipped over the proper bullet.

0 Kudos
Message 3 of 20
(3,763 Views)

Hi Guy,

 

if you would use csv files you could do your task as simple as this:

check.png

You know csv files are "excel files" too?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 20
(3,760 Views)

I asked for the example to see if you were actually reading from Excel or reading a "spreadsheet" file.

 

As was said, if you are using a CSV file, then you can read it directly in LabVIEW.  No need to interface with Excel.  If an actual xls(x) file, then you need to interface with Excel.

 

You can use the To Long Integer bullet to convert your array.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 20
(3,757 Views)

As I understand this Excel is just a tool to generate a table of values. It should be no problem to export that table into a csv file...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 20
(3,755 Views)

I read that I could export the excell sheet to a csv file just by doing a Save As and saving it as a .csv file. I did this, used the "Read from spreadsheet file.vi" and directed the file path to this new csv file. When I try to run the vi, I get an error message saying it can't find file. Possible problems are that the file no longer exists or the file path was not written properly. Both of those are not the case so I'm not sure what the problem is.

 

Is there maybe something else I need to do maybe with creating the csv file, directing the file path, or maybe am I not properly using the "read from spreadsheet file.vi"?

0 Kudos
Message 7 of 20
(3,737 Views)

Hi Guy,

 

maybe all you need to do is to close Excel before trying to access that CSV with a different program (like LabVIEW)...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 20
(3,735 Views)

Just to expand on what GerdW is saying.  There are many programs that hold exclusive access to a file.  So if a file is opened in Excel, the LabVIEW cannot access the file.

What is the exact error code?  Different error codes will point to different issues.

 

Make sure the csv file is exactly where you think it is and LabVIEW is pointing to the right place.  (I'm just going through stupid things I have done)



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 20
(3,730 Views)

I wish it were that simple. I did try that, and I still got the same error message. Do you know of any other applications that can create csv files?

0 Kudos
Message 10 of 20
(3,728 Views)