07-08-2016 06:26 AM
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
Solved! Go to Solution.
07-08-2016 06:34 AM
@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
07-08-2016 06:44 AM
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
07-08-2016 07:28 AM
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
07-08-2016 11:32 AM
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.
07-08-2016 03:35 PM
I would probably use variant attributes, especially if the arrays are large and it is critical to find the relevant entry fast. 😄
07-08-2016 05:26 PM
07-14-2016 03:25 AM
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
07-14-2016 07:18 AM - edited 07-14-2016 07:18 AM
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.