LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from a text file

Hi there,

 

We have a very simple question. We are trying to read ONLY the second colume of a text file using the "read from spread sheet.vi" and we are having difficulty doing this. The text file looks like the one attatched. We can't read the second colume because it is seperated by ",". At this moment we can only read the first colume.

 

Is there any other vi that can do this or can we just modify the "read from spread sheet.vi".

 

Can someone help us. Please!

 

Thank you.

0 Kudos
Message 1 of 12
(3,542 Views)

Hi conchita,

you can use the "read from spreadsheet file" function. Use a "," as delimiter. The result is a 2d array. You can use "index array" to get only the second column.

 

Mike

Message 2 of 12
(3,537 Views)

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 12
(3,504 Views)

hi mike

Thank you very much for your help....

Message Edited by conchita on 07-13-2009 09:22 PM
0 Kudos
Message 4 of 12
(3,483 Views)

Hi Jim,

 Thanks for your help. Your program does exactly what we were trying to do.Smiley Very Happy

 

 

0 Kudos
Message 5 of 12
(3,477 Views)

Hey,

 

Using your code we can get the 2nd colum of the text file and store it into an array. However now we are trying to save that data into an Excel file, in B2 cell. We are finding it difficult to do this.

 

We searched on the forum and found the following website, which we thought was helpful. But even with the help of the forums Smiley Sad we couldn't manage to save the date on an actual Excel file.

 

Can you please help?

 

Thank you

 

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=378727&query.id=847333#M378727

0 Kudos
Message 6 of 12
(3,464 Views)

Hi conchita,

the link shows no function to write into a real excel file. You need ActiveX to do that. See this link for some ActiveX functions.

 

Mike

Message 7 of 12
(3,450 Views)

Hey Mike,Thanks a lot for all your generous help. It’s really nice of you to provide us with so much assistance. Smiley Very Happy This is what we are trying to achieve. We are getting a vast amount of data in the in the file DATA123 format (attached before). So we want to create ONE big file with all the dBm values. This is what we thought we should do to achieve this:

 

1.       Open each of the files (at a time) and read of the 2nd column ( the code given by you)

2.       Paste it into a new file.

3.       Open a new file (formatted in the same way as DATA 123)

4.       Again copy the 2nd column.

5.       Paste it next to the existing set of data in the new file. [separated by “,” or space.]

We were trying to do it in a text file. We have added some vi to it. However it does not work at all. We hope that we have explained the problem to you clearly and also hope that it is not too much trouble for you Smiley Happy.  WE really appreciate ALL YOUR HELP.

 

THANK YOU.

Message Edited by conchita on 07-14-2009 02:20 AM
0 Kudos
Message 8 of 12
(3,437 Views)

Hi conchita,

the attached picture shows two solutions. The first stores all your data in one column, the second build an array where each column is the data from a new file.

 

Mike

Message 9 of 12
(3,420 Views)
How much data are you considering putting into a single file?  From your description, it sounds like you would be much happier with a structured binary file, such as TDMS or HDF5, than a text file.  It is very difficult to add columns to an existing text file, but easy to do for structured binary files.  The binary files will also give you faster access and smaller size.  TDMS is native in LabVIEW.  There are multiple HDF5 implementations in LabVIEW (the current best was probably done by Tomi Maila of ExpressionFlow).
Message 10 of 12
(3,403 Views)