LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search 1-D Array not working

Hi all,

 

Can anyone help me with the attached VI?  The "Search 1-D Array" does not seem to be searching.  The output is always -1, when I know that my data from my excel sheet that I am reading from contains the number 193.3359.  I intend to find how many rows in my excel data contains the number 193.3359, and I would like an output array to copy each row & all it's info.  (example: if there were 6 rows that contain the number 193.3359, i would like all 6 rows show up in the output array).

 

Thank you for your help.  I do not have a sample of my data, but it's about 2,000 rows and 10 columns.  They contain numbers & words.  Here I am just searching for a number.

0 Kudos
Message 1 of 16
(2,821 Views)

Can you attach a shortened version of your data file?

0 Kudos
Message 2 of 16
(2,802 Views)

I'm guessing that you have a precision issue.

 

Are you sure that the number is coming back as 193.3359 and not 193.335899999?

0 Kudos
Message 3 of 16
(2,800 Views)

Also, for code simplifictions you should...

 

  • use "built array" instead of "insert into array".
  • use the correct numeric representation for the numeric indicator (or delete it, because you won't be able to follow it by eye anyway, becausde the updates are so fast)
  • Wire the blue wire directly to the case structure selector and make one case -1 and the other the default.
  • ...

 

0 Kudos
Message 4 of 16
(2,798 Views)

Yes I can.  Here is something similar to it.  (a few more columns and many more rows of data)  In my previous post I was searching for 193.3359 under the T(sec) column, so let's say for this sample of my data I am searching for T(sec) = 6.1924.

 

Thank you!

0 Kudos
Message 5 of 16
(2,795 Views)

Well the vi you uploaded worked with test data I used, though there are a couple issues. The reason -1 keeps showing up is that when you run the vi essentially what you are seeing is the result for the last search you did, in which case, if the last row does not contain that value then you will see the -1, which indicates no index. That numerical value also only indicates the index where the value was found, so unless you need to know that information, you don't need it. Also, I had to remove the comma as the delimiter for my data as mine is tab delimited, but idk if you're data is in the form of csv or tab delimited but that could be an issue.

0 Kudos
Message 6 of 16
(2,791 Views)

You are running into rounding errors (most likely) This might work better

 

Match string.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 16
(2,786 Views)

@Taki1999 wrote:

I'm guessing that you have a precision issue.

 

Are you sure that the number is coming back as 193.3359 and not 193.335899999?



No, he's searching for raw strings so this cannot be it. This would be an issues with e.g. DBLs

 

 

Some other guesses:

  • The strings in the array elements contain leading or trailing spaces or other nonprintable characters.
  • The file has comma as decimal seperator (e.g. from a german computer).
  • ...

 

0 Kudos
Message 8 of 16
(2,784 Views)

That's an Excel file. Read From Spreadsheet does not read Excel - only plain text.

0 Kudos
Message 9 of 16
(2,773 Views)

Hmm, I was told it does, but they could be wrong, what would I use to read data from excel?

0 Kudos
Message 10 of 16
(2,767 Views)