Jump to content

Fastest string array/csv search


brownx

Recommended Posts

I have a CSV with data like:
Name  Addr Number
Paul     13      235
Sarah   1        15

I need the fastest possible way to get the Addr/Number pair which matches the searched name (exact match, occurs only once). The whole search will be called lots of times from a teststand - this is why I need to have it fast.

The simplest is to load the csv into array once than do a loop with string compare (fastest in this case probably being the string subset). 

Is there any faster way for achieving this without hardcoding the name,addr/number pairs into a switch/case?

Link to comment

The variant attributes is probably the fastest way for any decent sized table.  Otherwise you are using the search 1D array.  You can run some speed and performance testing to see which is faster for the data you have.  I'd recommend you watch some of the 2016 advanced user track videos on Benchmarking and Optimization...but NI's site is a bit broken at the moment and I can't find hardly anything, but this is where the session content is, videos are a bit harder to find.

http://forums.ni.com/t5/NIWeek-Session-Content/TS9524-Code-Optimization-and-Benchmarking/ta-p/3321074

  • Like 1
Link to comment

Made the code using variant just to find out TestStand have problems with passing variants ...

At least I did not succeeded to create a Global variable to hold a variant and pass it to the steps (tried container and object reference) - forums are full with this issue, I'll see what I can understand from them.

Update1:
Pfff - seems it is not working, at least not with my version of TestStand:
http://forums.ni.com/t5/NI-TestStand/LabVIEW-Variant-Attributes-get-lost-in-TestStand/td-p/3172358

Update2:
Managed to make it work with DVR - probably is even better since the 2-300 line lookup table is not copied in every step.

Edited by brownx
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.