LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

find string in array of strings and show next value in row

Solved!
Go to solution

Hi , i'm new i LV and i'm making a Vi that read values from spreadsheet and generates the 2d array of strings the same spreadsheet. For now all I need is a function that find specyfic string in this array, and show next value in a row. Like :

 

array :

a;b
c;d
f;g

example: find "c"

Vi shoud show "d"

 

Regards 

0 Kudos
Message 1 of 9
(6,451 Views)

@guziec wrote:

Hi , i'm new i LV and i'm making a Vi


Hi,

 

Post what you have tried so far. We will help you from there.

 

Mathan

0 Kudos
Message 2 of 9
(6,446 Views)
Solution
Accepted by guziec

Not a bad homework problem.  Do it with pencil and paper.  Write down your array, and pretend you are the computer.  What do you want to do (step by step)?  What questions do you want to ask?

 

Now translate that a bit to computers.  You mentioned that the data are in an array of strings.  What (LabVIEW) structures work with arrays?  [Do you know how to work with arrays?  If not, review some of the LabVIEW Tutorial Material -- see upper right part of Forum's first page].  What do you know about strings?  What question(s) do you need to ask about strings?  What do you know about string functions?

 

Put these things down into some LabVIEW code, "feed" it some data, and see what it does.  If it seems to be doing "unexplained" things, you can try watching the Block Diagram execute by turning on highlight execution (and if you don't know what that means, use LabVIEW Help and view the Tutorials).

 

Bob Schor
 

Message 3 of 9
(6,440 Views)

Go through Array palletes and its Help you can explore much

 

Hope Index array and search 1D array will help you to solve your problem

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 9
(6,426 Views)

I am seeing a FOR loop with a conditional terminal (to stop it once the correct value is found).  Inside of the loop should be a simple Search/Split String to find the ; and give you the strings before and after it.  If the before matches your search string, stop the loop.  Have the after match string go to a normal output tunnel on the loop.  The result will be the last value that was checked.  You may want to add some more code to change the value to an empty string if the search string was not found.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 9
(6,406 Views)

I would probably use variant attributes, especially if the arrays are large and it is critical to find the relevant entry fast. 😄

0 Kudos
Message 6 of 9
(6,386 Views)
Hope search 1D array of 0th column with respective input (assume c) will provide the index . With the achieved index , the respective element in 1st column element can be achieved
----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 7 of 9
(6,368 Views)

I make Vi like shown. Take 2D array and transpose it. Next search in 1st row suitable string. The function give me index of that string back. After that Vi search in 2nd row array of that index ( its an array but only one value (string))> array subset gets an value from that array. At the end is conversion from string to decimal. Thats how i solved the problem , thank you all for advices 🙂
cheers 

0 Kudos
Message 8 of 9
(6,277 Views)

1. You could just use the Read From Spreadsheet File (or in 2015 the Read From Delimited File) instead of the file read and Spreadsheet String To Array.  It is all done in that supplied VI for you.

2. You can use a single Index Array and expand it to get your two columns.  No need for the Transpose.

3. You can juse use an Index Array to get your single element instead of Array Subset, Array To Cluster, and Unbundle

4. Since you have a format of %.3f, I am left to assume you actually want to use the Fract/Exp String To Number, which will give you a floating point number instead of an integer.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 9
(6,266 Views)