LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search string and return data

Solved!
Go to solution
Use Index array and take 1st (and 2nd) column as 1D array, then search.
0 Kudos
Message 11 of 17
(605 Views)

@rafael.assis16 wrote:

Hi, I'm new to labview. I have a string (Data1: A, Data2: B, Data3:C.......), I need to go through this string to fetch the data, regardless of the order. Example: look up Data2 and return only B. But I need to do this for a set of Data1 or Data2 and etc, my string will contain a lot of data.


From what the OP wrote, I'm not sure if all the "Keys" in the Key:Value pairs will be unique. i.e., it sounds like there could be multiple entries for Data1. So I was thinking how best to extract all the data for each unique Key. I'd seen a method that used variant data (apologies for not knowing the author). I modified it somewhat because the indexing tunnel forced the 2D array to have the maximum dimensions with the default being "0". IMO zero could be a valid value so I tried to force the default to be "NaN" instead. Looks kind of Rube Goldberg-ish.

 

Would this be the best/easiest method to sort the data?

 

Sort Data by Keys.png

 

fp.PNG

 

Message 12 of 17
(601 Views)

My labview is 2012, do not open the file.

0 Kudos
Message 13 of 17
(589 Views)

@rafael.assis16 wrote:

My labview is 2012, do not open the file.


Are you referring to my VI? If so, here it is in ver. 2012

Message 14 of 17
(585 Views)

I liked your solution, but I have a problem because my data is strings and you do a string conversion for number. Another thing, I wanted to look for one or more values ​​within that defined list, in this example it brings the result of all variables.

0 Kudos
Message 15 of 17
(578 Views)
Solution
Accepted by rafael.assis16

@rafael.assis16 wrote:

I liked your solution, but I have a problem because my data is strings and you do a string conversion for number. Another thing, I wanted to look for one or more values ​​within that defined list, in this example it brings the result of all variables.


It sounds like the variant method is overkill for what you want to do. If it's just to extract all the values for a single key (like "Data 1"), it probably would be easier just to use a conditional tunnel. You can decide which method is better for your application.

 

I changed the indicators to be strings instead of DBL.

 

Easier Method.png

Message 16 of 17
(556 Views)
Thanks a lot for the help.
0 Kudos
Message 17 of 17
(536 Views)