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

.....................

………………

(keeps growing)

 

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.  My line items seem to be growing exponentially and is getting difficult to manage in the LV window.

 

Thanks

0 Kudos
Message 1 of 2
(3,500 Views)
Solution
Accepted by topic author diverdan95

Unless your CSV file is huge, I'd use "Read from Spreadsheet File" with the delimiter set as "," and the type as string.  This will give you a 2D array of strings.  You could then separate out each column of the array, convert to the appropriate data type, and use Index & Bundle Cluster Array to build your array of clusters.  Something like this (except I'm using a string constant in place of reading from the file).

 

spreadsheet string to array of clusters.png

Message 2 of 2
(3,495 Views)