LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing strings from an array with a search string

Solved!
Go to solution

Hi guys,

I can't seem to figure out any solution to the this exercise where I have to search a text file for a string entered at the front panel which denotes a "property name" and then returns an associated "property value". Basically I have already populated an array in memory full of names and property values. 

 

When this new project is executed it is supposed to find this file in memory and compare the property name column with the name search control. If it finds a match it outputs its corresponding property value. Screenshot (63).jpgThe program isn't fully conceptualized and there are probably more problems than the one I am trying to fix so please bear with me. The property name is in the first row first column so I go to a for loop where I use the array subset function to look in the ith row and first column and create a sub array based on this.

 

Only trouble I have now is this is a sub array and not a string. I can't enter the value into the equality comparator and into the case statement to then print out the associated property value unless both inputs to the comparator are strings. At first I assumed the sub array would work like a string and be able to be compared with strings but when I put it into the case statement it tells me the sink and the source are 2 different types of data.

 

Any tips appreciated,

Simon. 

0 Kudos
Message 1 of 3
(3,618 Views)
Solution
Accepted by topic author sburt0n

Hi Simon,

 

I have to search a text file for a string entered at the front panel which denotes a

"property name" and then returns an associated "property value".

Some simple steps:

1. read the CSV file using ReadSpreadsheetFile (as an array of strings)

2. Index the first column from that array

3. search the user input in this 1D array using Search1DArray

4. use the found index to index an element of the 2nd column of your CSV array (don't forget to check for a "not found" condition!) using IndexArray

5. convert the found "value" from string to number using any of the StringToNumber functions

 

Your image shows you have problems to understand basic LabVIEW concepts like autoindexing on loop borders: you really should take the beginner courses offered in the header section of this LabVIEW board!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 3
(3,609 Views)

Thanks for that. I got it to work. 

0 Kudos
Message 3 of 3
(3,564 Views)