LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

scan from file to extract a string

Hello, people
 
I'm trying to use the 'Scan From File' in order to search in a specified text file for a certain string and after I find it I want to extract another string next to the 1st one or in a few spaces from it. It is actually to find a parameter and extract its value. Generally the text looks like the following:
 
text text text text text text text
text param1 = value1 some text
text param2 = value1 some text
----------------------------------------
text specified param = value some text
text paramn = valuen some text
text text text text text text text
 
My problem is that I don't know how to search for a string made of several symbols separated by spaces an how to extract the value after the specified string. I'm new to LabVIEW and really stuck with this problem.
 
I would be grateful for your help.
Thank you in advance.
Dima
0 Kudos
Message 1 of 9
(4,445 Views)
Sounds like you might be trying to re-invent the wheel a bit here.

Try taking a look at the 'File I/O' pallette and under there you will find some 'Configuration VI's' these are used to do something very similar to what you have in mind... perhaps exactly..
0 Kudos
Message 2 of 9
(4,435 Views)

Thank you for such a fast response. Not expected.

I've tried 'Read Key' and it did not wrk. I think it can work only with the config file, but not any txt or dat file. It is also written so in the LabVIEW Help.

To use the 'Scan From File' I have to format my string in the correct way, but those spacings are killing me. This is the problem actually.

May be you right as for the wheel, therefore I keep looking and asking.

Thank you one more time.

Dima

0 Kudos
Message 3 of 9
(4,431 Views)
I usually just use the Match Pattern and Scan From String functions. The Scan From String function can also output data as decimal numbers (%d), floating point (%f) or almost anything else.
0 Kudos
Message 4 of 9
(4,426 Views)

Thank you for your help.

It seems it will do it. I think that before using your method I have first scan the entire file and build from it a string. Can you, please tell me how to do it.

I'm a newbie and your help is invaluable for me.

Thanks a lot.

Dima

0 Kudos
Message 5 of 9
(4,421 Views)
I know how to read the file, but how to make a string of it I don't.
I'll keep looking and waiting.
Thanks.
Dima
0 Kudos
Message 6 of 9
(4,415 Views)
The easiest way to get a string from a file is to use the Read Characters From File function. Its on the File I/O palatte. This will only work if your file is some sort of text file (most data files I encounter are text files). If this doesn't work for you then post a sample file.
0 Kudos
Message 7 of 9
(4,413 Views)
Thank you very much!!!
I'll try it tomorrow first thing and also will try not to bother you Smiley Happy
Truly yours.
Dima
0 Kudos
Message 8 of 9
(4,403 Views)

Hello, people

I have finally succeeded in reading a text file and find inside it a specified parameter. Many thanks to nissen6, I'm really grateful. It works with Read from Text File (probably that's what you meant for Read Characters From File) with acount -1 to read the entire file, and then as you suggested Match Pattern and Scan String. Works marvellous. Thank you one more time.

0 Kudos
Message 9 of 9
(4,370 Views)