06-12-2018 10:58 AM
Trying to search string in the file by read delimited spreadsheet, but result is not accurate.
for example,
i need to find the operator name so im finding the index of operator name.
Solved! Go to Solution.
06-12-2018 11:05 AM - edited 06-12-2018 11:06 AM
Your code makes no sense at all. can you save it with your desired default data in the "element" control? Currently it is blank. You should also set that control to "limit to single line", else you might get a stray linefeed in there, which would fail the word match.
Is the operator name always at the same index? If not, use "index array" to get the first column and use "search 1D array" to find the word "Operator Name", then use the found index to index into the second column to get it.
06-12-2018 11:19 AM
in code you can see that im comparing the element (input from user) to the array element(2d array retrieved from file) but led is not on.
forget the rest of the code.
just for checking code i used constant in index array.
0,0 element in array is date and inputelement from is date too but led is not on.
06-12-2018 11:56 AM - edited 06-12-2018 11:57 AM
You need to be very careful when comparing strings. Any little thing can cause a failure in the comparison. In your exact case, there is an extra space in the file. So unless you handle that or your user knows to add a space at the end, your comparison will fail.
My suggestion is to use Trim Whitespace on both the user input and the data from the file and then do the Equals. If you want to be safe as far as case is involved, then you can also throw in a To Upper Case on both as well.
06-12-2018 12:03 PM - edited 06-12-2018 12:07 PM
Yes, you name contains leading and trailing spaces, so a comparison requires identical strings to succeed. Make sure they really are. Here's what I would do to get the operator:
Here's how your array looks using \-codes display.("\s" is a hidden space character)
06-12-2018 12:13 PM
Thanks
even i resolved the problem but thanks for helping.
Using trim whitespace is a good idea.