LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading from file

Solved!
Go to solution

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.

Download All
0 Kudos
Message 1 of 6
(2,815 Views)

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.

0 Kudos
Message 2 of 6
(2,811 Views)

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.

Capture.PNG

0 Kudos
Message 3 of 6
(2,800 Views)
Solution
Accepted by topic author luckysam

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.


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
Message 4 of 6
(2,785 Views)

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:

 

GetOperator.png

Here's how your array looks using \-codes display.("\s" is a hidden space character)

 

Spaces.png

Message 5 of 6
(2,780 Views)

Thanks

even i resolved the problem but thanks for helping.

Using trim whitespace is a good idea. 

0 Kudos
Message 6 of 6
(2,768 Views)