01-09-2014 05:37 AM - edited 01-09-2014 05:42 AM
Hello!
I wonder if I could get your help on extracting data from text file.
I have a text file separated by rows which looks a bit like that:
0.0000012345 4
0.0000012355 4
0.0000012456 6
0.0000012569 4
0.0000012577 7
0.0000012621 4
0.0000012742 6
0.0000013489 7
0.0000013789 4
0.0000014569 7
The text file consists of about 16 million of such rows, I need to extract the information between certain rows, for example, between rows 3-5 and 8-10, etc. I've been using a function: Read from Spreadsheet File vi. but it only allows me to read the required number of rows at a certain character offset. The number of characters per row is not fixed and therefore it's impossible to relate the number of characters to rows.
Is there a vi that would let me access the desired rows throughout the entire file withough the need to count the charactes?
Your help would be much appreciated!
Many thanks,
Agata
01-09-2014 07:15 AM
You can configure the Read Text File to read lines. It is a Righ-Click option. So I would just read the lines that you want to ignore just to set the file pointer to the beginning of your data. You can then read the data you care about using whatever method you want.
01-10-2014 07:45 AM
Unfortunately, LabVIEW does not buffer file data in line read mode very efficiently, so reading lines in one at a time for a file with millions of lines is probably going to run into major performance issues. If it works for you, go for it. If you have performance problems, you can do the following:
This may sound like a lot of work, but you will get a 2X to 10X or more performance improvement, depending upon your hardware and LabVIEW version.
There is an example of this embedded in the code on this post, but it is wrapped in a fairly complex, object based file system. Approach with caution and read the comments on the original post before proceeding.
01-10-2014 08:50 AM - edited 01-10-2014 08:51 AM
Actually, you do not have to use any programs other than LV to find the EOL character(s). Just write a quick VI which will read in from a typical file enough data so you know you'll have at least one EOL in it, and put an indicator on the FP for the data string. Right-click on the indicator and set it to show "\ Codes".
Cameron