LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read CSV file into a 1-D array

Solved!
Go to solution

Hi

 

I would like to read a csv file into a cluster of 4 elements
which would then be read into a 1-D array. 
My cluster contains a typedef, a double, a boolean, and another typedef. 

Basically it could be seen as:

Bob Runs, 4, T, Bob

Mary sits, 5, F, Mary

Bob Sits, 2, F, Bob

Mary Runs, 9, T, Mary

………………

 

Are there any good
examples for what I am trying to put together that I could leverage, or is it
better to use a different input file than a csv.  I am trying to make my program more flexable
and easier to make adjustments even after the executable is created.

 

Thanks

 

0 Kudos
Message 1 of 5
(5,010 Views)

Did you mean to post this in Signal Express or the LabVIEW forum? You don't specifically state in your post which but it sound like you might be asking for help importing text into labview.

 

You can make a 1D cluster array in LabVIEW that will allow you to index each row and then you can unbundle each entry as you need.

Kyle Hartley
Senior Embedded Software Engineer

0 Kudos
Message 2 of 5
(4,990 Views)

Sorry, I must have selected the wrong forum by accident

0 Kudos
Message 3 of 5
(4,984 Views)
Solution
Accepted by topic author diverdan95

No problem. I went ahead and sent a mod a post to move this to the correct forum. 

 

Anyway, there is a subvi included with labview call "Read from Spreadsheet File.vi". You can find it in the Programming palette in the Fuctions window. You should be able to read your csv file with this and place it in a 2D array of strings. If you want certain types you'll have to do some more conversion. You could use a case statement to check if column 3 is T/F and then output a boolean value to insert into your array of clusters.

 

Read from Spreadsheet file Help

 

This should get you started. If you have any questions please feel free to ask.

Kyle Hartley
Senior Embedded Software Engineer

Message 4 of 5
(4,972 Views)
0 Kudos
Message 5 of 5
(4,958 Views)