LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read from text file and seperate column

hello,

I have a problem reading my text file. This text file is downloaded from weather link. All data will be changed upon the selection of user. my problem is I can read the data column by column but i cannot retrive the right column header for each data. I also attached the test file. Can somebody help me? Thanks in advance..

Download All
0 Kudos
Message 1 of 8
(5,374 Views)

Your downloaded file contains one or more spaces to separate the columns. This isn't supported directly by read from spreadsheet file.

You have to read the file first, replace one or more spaces by one space and use read from spreadsheet string using space as delimiter.

 

See attached image. Search/replace is set up to use regular expressions. The search term is " +" (matches one or more space character), the replace term is " " (a single space character).

 

0 Kudos
Message 2 of 8
(5,366 Views)

Hello,

Thanks for quick reply. I am now using Labview 8.5. so i don't have "Read lines from files.Vi". but i tried like the following attachment. i still cannot read right column.

0 Kudos
Message 3 of 8
(5,354 Views)

Read from lines.vi still exists in 8.5, it's just not on the palette. You can also just use "Read text file". See attachment.

 

0 Kudos
Message 4 of 8
(5,351 Views)

Hello,

 

Thanks for ur reply.i can retrive the data except first 2 rows.. the problem now i facing is i cannot retrive the first 2 rows [column header] correctly. i show the problem in attached file. I cannot insert directly the column header because the downloaded data will be changed upon user's selection.

0 Kudos
Message 5 of 8
(5,307 Views)

Hi

 

Sorry, I missed that one. The file formatting is strange though. It uses spaces to separate columns but also within columns. I attached a modified VI that tries to take care of that, but it fails at the columns "Solar Energy" and "Hi Solar Rad.". This is very difficult to read programmatically as there's one space each between "Solar", "Hi", and "Solar" again. So how do we distinguish between column separator and space within column?

Is download.txt the original file? Or was it probably modified by an editor that would replace tabs by space characters?

 

 

0 Kudos
Message 6 of 8
(5,291 Views)

Hello,

 

thank you very much for your helps and patience. The one i sent is the original downloaded text file. nothing changes has been made.. :'(. if so, no way to retrive data programatically?.. :'(.. anyway, thank you very much again for ur helps.

0 Kudos
Message 7 of 8
(5,284 Views)

Hi,

 

You can of course add some "intelligence" to the read routine (see attached). But this is not the favorite way to write read routines. The problem might reoccur with another column header.

 

0 Kudos
Message 8 of 8
(5,281 Views)