LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extracting a number from a text file

Greetings!

I am looking at developing a vi to extract some numbers from an oddly arranged text file. I would rather not try to modify the program that makes the file as it wasn't written by me and is rather scary to look at (it wasn't coded well and breaks easily when messed with).

The program creates an individual file as shown in the attachment. It then appends another set of data in the same arrangment. It does this up to 144 times, depending on how much data is accumulated prior to being read.

What is the best way to extract the numbers at the end of each line? Should I pull it into an array and index out each point? Or should I scan the text and single out the numbers from the rest? Or is there some easier way? I'm using this as a learning oppurtunity and would like to have the proper route to tackle this up front rather than write some kind of Frankencode and find out later that, silly, I could have simply done 'X' and saved hours of development.

By the way, I am using version 7.1 in case someone asks.

Tay
0 Kudos
Message 1 of 4
(2,460 Views)
If all you need is the numeric data, consider using the Search/Split String VI (hint: the "="  in your text file looks common to the lines with numeric values). Get your data from the file into an array of strings to use that VI effectively.

Just one of several ways to parse the file. All depends on how much you can assume about the structure of your data.

Message Edited by Bill@NGC on 07-18-2007 08:17 PM

Message 2 of 4
(2,448 Views)
Reading in the file is the easy part. The attached shows the simplest way. The problem is that there isn't any consistency to each rows format, i.e. it isn't a number at the end of each row, some having "units" or spaces.  Ideally these text data files are saved with a standard char between the elements, tab delimited, commas (CSV), etc. making it easier to parse. If all you are interested is are the numbers "near the end" then the individual rows of the array shown can be parsed for the chars between 0-9 and decimal points. A little annoying, but not terribly.


Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 3 of 4
(2,445 Views)
Say, just wanted to let you know I finally developed a way to handle this file. It is kind of a brute force approach, but it woks. See the attached. Thanks to both of you for the help!

Tay
0 Kudos
Message 4 of 4
(2,386 Views)