LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read one column from many columns in .csv file?

Hello Everyone,

                      Can anyone please tell me how to read one column out of many columns in a .csv file using normal LV techniques?

 

I did see many of examples where they had toolkits, but can anyone suggest me some codes without those toolkits?

 

I have 5 columns; 1st is time column and the rest contains numbers.

 

ANy help is appreciated

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 1 of 11
(11,617 Views)

Capture.PNG

 

Capture.PNG

=====================
LabVIEW 2012


0 Kudos
Message 2 of 11
(11,610 Views)

Read all columns, then use "index array" to get the desired column.

 

Column values are not adjacent in the file, so trying to "surgically" read columns is impossible. You would need to read every single byte of the file anyway in order to see where the commas are and thus where the column values start.

0 Kudos
Message 3 of 11
(11,607 Views)

altenbach, thanks a lot for the reply, but i have a column full of numbers, also, i want to display one column in 1 array, next column in 2nd array and so on... how can we do it?? The values are 'tab' seperated ... if i am not clear, please let me know...

 

once again, thanks a lot

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 4 of 11
(11,583 Views)

As I said, you read the entire file into a 2D array, then use "index array" to slice out any column you like. Where are you getting stuck?

0 Kudos
Message 5 of 11
(11,578 Views)

i could get only 1 column to read and save into an array... i cannot get the next column to read, i dunno how to create a multi-dimensional 

array which can save up ALL the column data, and then later on, i can index the arrays like you mentioned...

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 6 of 11
(11,569 Views)
In the first post you said you had 5 columns, now you only seem to have one. Can you show us some simplified code so we can see where the problem is? How do you save? How do you read?
0 Kudos
Message 7 of 11
(11,564 Views)

altenbach, i still have 5 columns, its only that i want to read 1 column, save it in an array, and display that column on a waveform chart...

 

similarly do this for all the remaining columns...  well, i got the code to read one column at a time, by converting .xlsx file to .txt with tab limited option selected (while saving .xlsx to .txt)

 

next thing i would like to do is:

 

1. column 1 in excel file is a time stamp. The time stamp is in hr:min:sec format.

2. column 2 in excel file is a date stamp in the format DD:MM:YY

 

    how can i make LV read the time and the Date stamps from an excel file...

 

I will post my code soon, its on a laptop to which i dnt have internet access.

 

 

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 8 of 11
(11,540 Views)

Your code should be reading the entire file at once with the Read From Spreadsheet File function. Set it to read strings. This returns a 2D array which you can easily index.

0 Kudos
Message 9 of 11
(11,534 Views)

You should be able to do this in the following manner:

 

FrontPanel.png

 

BlockDiagram.png

 

Best of luck!

 

Lynn

National Instruments
Senior Systems Engineer
0 Kudos
Message 10 of 11
(11,505 Views)