LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I extract data from array of strings?

I tried to look for a solution to this but I haven't got any yet, I just started labview and I am trying to do a simple data extraction ui.
 
Basically if i have an array of strings, i'd like to filter out specific items from it using pattern matching then dump it to another array.
 
I tried with a simple for loop but it adds empty strings to my second array.
 
The array was supposed to contain this strings and i just want to pull out the ones with 5_visualid_.
 
2_test1
3_test2
4_test5
5_visualid_unit1
2_test1
3_test2
4_test5
5_visualid_unit2
2_test1
3_test2
4_test5
5_visualid_unit3
 
thanks


Message Edited by peter.a.azucena@intel.com on 05-06-2008 10:26 PM
0 Kudos
Message 1 of 15
(4,570 Views)
Try this. Your problem is that the function either returns the string you are looking for or an empty string. The case statement will create an array of only those strings where the search is successful. The modified VI is pretty similar to the shipping example called Separate Array Values in the Fundamentals>Arrays and Clusters section
0 Kudos
Message 2 of 15
(4,560 Views)

I think you cannot search an array for varying elements using the Match Pattern function & delete them.

Maybe you can see the VI attached to get an idea of how to do it. Smiley Happy

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 3 of 15
(4,554 Views)
both examples are great. thanks a lot!
0 Kudos
Message 4 of 15
(4,552 Views)
Just always rt-click your control & Make Current Values Default & then save the VI before posting it in the forums.
This will ensure that we can have your test data ready. Smiley Happy
 
No need to type them in the post literally. Smiley Wink
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 5 of 15
(4,551 Views)

Peter,

I think I misunderstood your requirement & Dennis is correct.

Which is the one you needed?

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 6 of 15
(4,549 Views)

Peter,

You can also go thro' this link to read more.

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 7 of 15
(4,541 Views)
Dennis example are actually more simplier and with this i can continue with my next task, I've updated the VI below where i am now extracting 3 different items, the code work but i'm sure there is a better way to do this, also, if for some reason one of the result is not there, i was hoping it will fill up the cell blank but it doesn't.
 
 
 
 
 
 
 
 
 
 
0 Kudos
Message 8 of 15
(4,489 Views)


peter.a.azucena@intel.com wrote:
Dennis example are actually more simplier and with this i can continue with my next task, I've updated the VI below where i am now extracting 3 different items, the code work but i'm sure there is a better way to do this, also, if for some reason one of the result is not there, i was hoping it will fill up the cell blank but it doesn't.

Your "failed" result starts with a "5_result...", but you are checking only for "4_result..." No match!.
 
If the pattern is always 4 in a row and sorted the same way (it probably is), you can do something like in the attached.
0 Kudos
Message 9 of 15
(4,474 Views)
Sorry it was supposed to be 4_result_, unfortunately the sample that i gave here is only small portion of my project and the input will vary, some may have 60 lines per unit some maybe 40 so i cannot use the array size, i have to use a pattern matching or regular expression to do it, I've done this in perl scripting which is similar to this:
 
 
open(DATA, "datalog");
while(<DATA>){
if (/3_prtnm_(\d*)/){
 
}elsif (/5_visualid_(\S*)/){
 
}elsif (/4_result_(\S*)/){
 
}
 
 
close(DATA);
 
 
 
 
 
 
0 Kudos
Message 10 of 15
(4,472 Views)