03-13-2018 05:30 AM
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. The 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.
Solved! Go to Solution.
03-13-2018 05:44 AM - edited 03-13-2018 05:45 AM
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!
03-13-2018 10:30 PM
Thanks for that. I got it to work.