09-05-2008 03:47 AM
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..
09-05-2008 04:08 AM
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).
09-05-2008 04:59 AM
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.
09-05-2008 05:06 AM
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.
09-07-2008 08:33 PM
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.
09-08-2008 02:10 AM
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?
09-08-2008 03:19 AM
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.
09-08-2008 03:26 AM
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.