LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to search a character string from a txt file?

i have a txt file. Its content is as the following :
Item 1,Pass;
Item 2,Fail;
Item 3,Pass;
Item 4,Fail;
Item t,Fail;

i want to by searching "Fail" string to realize the filter function to this txt file and output a table in the front panel just list the Fail item . how to do it ? Thanks!
0 Kudos
Message 1 of 9
(3,237 Views)
Hello,

attached is the solution...
0 Kudos
Message 2 of 9
(3,232 Views)
Hi
may be this will be of some help to you

Bhaskar
0 Kudos
Message 3 of 9
(3,225 Views)
The Bhaskar's solution is not good at all .... Try it with a 20000 lines file and see the diference :))) ... the time is better for my offered solution ...
He should open the previous solution ... and can learn a little bit 🙂
0 Kudos
Message 4 of 9
(3,221 Views)
hey dude, i can definetly learn from ur solution.
i was not able to open it, coz its in labview 7.1 and i have 7.0
can u post a labview 7.0 compatible solution
thanks:)

Bhaskar
0 Kudos
Message 5 of 9
(3,209 Views)
But if you want to see a real speed up in your example, eliminate all of the local variables. With a shift register, there's no reason for them. They just create copies of the data and really slow things down. Don't need the sequence structure either.:)

Message Edited by Dennis Knutson on 04-20-2005 09:05 AM

0 Kudos
Message 6 of 9
(3,207 Views)
Dennis is absolutely right. Both presented solutions are quite inefficient for this task.


A more efficient approach is shown in the attached VI (LabVIEW 7.0). It can easily be modified according to the desired output (table, 1D array if strings, simple string, etc.).

The original question asked for an output in a table, so that's what I did. To simply list them in a string indicator, you would initialize the shift register with an empty string, then concatenate the found line and a newline character in the default case.

(There are a few thing that would speed it up further but it's probably not worth the extra code. How big are your files?)

Message Edited by altenbach on 04-20-2005 08:54 AM

0 Kudos
Message 7 of 9
(3,196 Views)
Here's a slightly different version showing 3 possible outputs. (It only shows the failed items instead of the entire lines with failed items).
0 Kudos
Message 8 of 9
(3,180 Views)
Just used above FindFail for a similar application to basically count everytime a certain character appeared in my string. Works great after a little tweaking. Thanks for posting it, as I can now stop pounding my head against this particular brick wall!!!!!!!

AB
0 Kudos
Message 9 of 9
(3,168 Views)