LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

text parsing into proper array

I think I have been staring at this too long.  I am working with very old equipment.  It gives me the attached test.txt.  I need to parse it to where I can pull individual variable.  I can't parse it to proper array because it has different number of 'white space'.  I was wondering can any help me with this.
0 Kudos
Message 1 of 6
(3,319 Views)

Hi Sendtohen,

i think you can use the read from spreadsheet file function. You will get an 2D array of your data with which you can work then. You can delete the empty elements between elements with data and work with it.  I think your data format change in line "Sys_alarm" is it correct? I think til there you need a 2d Array and all other values are single ones.

 

Mike 

0 Kudos
Message 2 of 6
(3,312 Views)

Thanks for the quick reply.  Maybe, I didn't describe my problem clearly.  Because of different number of spaces it returns, I can't really just read in using the spreadsheet function.  The data would be in different cells all the time, because of different number of digits.   This is one of the reason why I am having such a hard time with this parsing.

 

Henry

0 Kudos
Message 3 of 6
(3,307 Views)

Hi Henry,

i understand it. But you can first read your file with it. You can also read it as a "normal" text file. I played with your file and attached you can find a picture which shows how it´s possible to replace the multiple spaces with only one space.

 

Hope it helps.

Mike 

Message Edited by MikeS81 on 08-24-2008 09:25 PM
Download All
0 Kudos
Message 4 of 6
(3,299 Views)

I think a considerably easier solution is to use the Scan From String function. You can read in the file into a string and then separate at linefeeds to give you an array. You can then auto-index this array into a for-loop and parse it out as you need it. For example, to parse out the line that contains "POS":

 

 

The output cluster contains the numbers -531, -8292, and 0.

You will need to determine what data you want and how you want to "package it" for program use. 

 

Message Edited by smercurio_fc on 08-24-2008 02:32 PM
0 Kudos
Message 5 of 6
(3,289 Views)

Thanks for all the help.  You guys have given me different ideas on solving this problem.  It is very much appreciated.

0 Kudos
Message 6 of 6
(3,274 Views)