LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I have to define a regular expression to filter out data from file?

Hi all,
 
I need to extract parts of lines of a ASCII file and didn't get it done with my low knowledge of regular expressions Smiley Mad
The file contains hundreds of lines and I am just interested in a few lines, within that lines I just need a part of the data.
One original line looks like that:
 
TP3| |TP_SMD|Nicht in Stueckliste|~TP TP_SMD TESTPUNKT|-|0|87.770|157.950|0|top|c| |other|TP_SMD|TP_SMD_60RF-TP
 
Only the bold and underlined information is of interest, I don't need the rest.
 
I can open that file, read in each line but then I am struggling to pick out only the lines of interest (starting with TP), taking that TP with its number and the coordinates following later on and then writing these shortened lines to a new text file. So the new line should look like that:
TP3; 87.770;157.950;0 (It doesn't matter if the separator will be ; or |)
 
I thought of using regular expressions - is that the right way or is there a better approach?
 
Thanks & regards,
gedi, using LabVIEW 8.5
Regards,
gedi
0 Kudos
Message 1 of 7
(3,307 Views)
Hi gedi,
you can use the "spreadsheet string to array" function. In the array you can use the index array function to get the interesting values.
Mike
0 Kudos
Message 2 of 7
(3,296 Views)
Hi Gedi,
Here is an example of what Mike suggested.
Jim

LV 2020
0 Kudos
Message 3 of 7
(3,291 Views)
Hi Mike, Jim,
thanks, this solution is a lot easier and I got it running!
 
Rgds,
gedi
Regards,
gedi
0 Kudos
Message 4 of 7
(3,254 Views)

hi,

I have an other problem like Mike,
i need to filter line  where a string is exactly the same that i put into a parameter.

more precisely, i need to read case on a data base in access or SQL format.

It is possible?

Thanks for your help Smiley Happy

and excuse me fore my english Smiley Sad



Message Edité par max_fr le 04-23-2008 03:59 AM
0 Kudos
Message 5 of 7
(3,241 Views)
Hi max,
for finding a specific part of a string you can use the "Match Pattern" VI, it is located in the Strings Palette.
Maybe the Extract Numbers.vi example in the examples browser library can help you.
 
What I did to filter out my data of interest is first to sort out only the columns which I want to have -
then there are still a lot of lines remaining I don't need (this is the thing described above).
The rest I am going to filter out with a (then easy) regular expression with the "Match Pattern" VI.
 
Regards,
gedi
 
Regards,
gedi
0 Kudos
Message 6 of 7
(3,235 Views)
Hi Gedi,
 
thanks for your answer i'll try this when i have anderstand how does it work.
 
max
 
0 Kudos
Message 7 of 7
(3,224 Views)