04-02-2016 11:41 PM
I would like to read in a text file which has a different format from standard text files supported by labview (XML, lvm tdm/s etc.). Basically my interest is to be able to by pass all the uneccessary characters on the header and go right to the channel names and onwards to the actual data.
I know there is a special character that marks the beginning of the channel names in this file.
So i need labview to be able to tell what the channels are (start to end of the channel names) as well the corresponding data following the channel names, (probably by searching /parsing for this special character).
Thereafter i finally want to be able to read the file in just like one can do by using the "read from measurement file" function and output that as a dynamic data signal.
I am not conversant with parsing and reading in text files, so kindly provide as much as details as possible.
Thanks.
04-03-2016 12:14 AM
Just read the entire file as one long string and use string parsing functions on it. Then convert the data part to a 1D or 2D array. Afterwards you can convert that to dynamic data (but why would you want dynamic data????)
04-03-2016 12:46 AM
04-03-2016 11:19 AM
@blessedk wrote:But can you explain "reading it in as a long string and then parsing".
Let's start with "Reading it in as a long string". Have you done any LabVIEW Programming? Have you viewed any (and all of) the LabVIEW Tutorials referenced on the upper right of the Forum's Start page?
On the Files Palette, there is a function called Read from Text File. Read its Help description (put the function on an empty Block Diagram, right-click it, and choose "Help"). You should see that if you wire a String Indicator up to its Text output and run it, it will (a) ask you for the File you want to read, and then (b) will give you the contents of the file as an array of characters (otherwise known as a "string"). You should then Close the File (there's a function for that, too).
Parsing a String means using the Functions on the String palette to do various things with the String, often to split it into sub-strings that you can place in a 1D Array of Strings. Note that you probably do not want a 2D array of Characters (unless all of your Strings contain exactly the same number of characters).
Try doing this. Develop some code. It might not work, but if that is the case, come back here, post your code (which means "attach your VI" -- do not attach a picture!!), and ask for help, describing the problem you are having.
Note that it might also help to attach the file that you are trying to read and parse (so we'll have access to the same data that you are trying to use).
Bob Schor
04-03-2016 11:52 AM - edited 04-03-2016 11:53 AM
Start reading here, then folllow the links on that page.
Actually, it will read it as a plain string, I would leave the word "array" out of it, because it can confuse. If you want to read it as an array of strings where each array element is a line, you can switch the mode to "read lines".
And if you wire a path directly to the upper left, you don't even need to close the file. (It will open and close automatically, see the help).
Also, make sure to disable "convert EOL" if you want to read the file content "as is".
04-03-2016 01:45 PM
04-03-2016 01:47 PM
04-03-2016 01:56 PM
04-04-2016 09:54 AM
@blessedk wrote:
That's one good point to note too. Potentially very large. Up to 1GB or more.
Are you sure there is only one header in the file?
Ben
04-04-2016 10:11 AM
Another note...
Very large text files will take some time to process. I recently did an application that required reading frmo 2G plus text files and even after I converted them to raw binary files, patience was required.
Ben