Jump to content
brownx

Fastest string array/csv search

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.


  • Similar Content

    • By Porter
      View File Robust CSV
      This package contains VIs for reading and writing to CSV files that follow the CSV format outlined in RFC-4180 (see http://tools.ietf.org/html/rfc4180). Using this package, you can properly import CSV files that were exported from spreadsheet programs such as Microsoft Excel, Open Office or LibreOffice Calc as well as export CSV files that will be compatible with any program capable of interpreting CSV files.
       
      This implementation of the CSV format is capable of handling escaped fields such as those containing commas (or other field delimiters), multiple lines, and double quotes.
       
      Notes:
      - Starting from V1.1.0, library files are located in "<LabVIEW>\vi.lib\LAVA\Robust CSV" and example is located in "<LabVIEW>\examples\LAVA\Robust CSV".
      Development version available on GitHub: https://github.com/rfporter/Robust-CSV
      Submitter Porter Submitted 02/21/2014 Category Database & File IO LabVIEW Version 8.6 License Type BSD (Most common)  
    • By Porter
      This package contains VIs for reading and writing to CSV files that follow the CSV format outlined in RFC-4180 (see http://tools.ietf.org/html/rfc4180). Using this package, you can properly import CSV files that were exported from spreadsheet programs such as Microsoft Excel, Open Office or LibreOffice Calc as well as export CSV files that will be compatible with any program capable of interpreting CSV files.
       
      This implementation of the CSV format is capable of handling escaped fields such as those containing commas (or other field delimiters), multiple lines, and double quotes.
       
      Notes:
      - Starting from V1.1.0, library files are located in "<LabVIEW>\vi.lib\LAVA\Robust CSV" and example is located in "<LabVIEW>\examples\LAVA\Robust CSV".
      Development version available on GitHub: https://github.com/rfporter/Robust-CSV
    • By Huqs
      Hello Labview Users, 
      I happen to have thousands of csv data file that I work with. The only way I recognize them is putting their characteristics in the file name. Which brings the problem of making the names too long and Microsoft doesn't like to accept long name. So I wanted to build a database for all my files. I am in the preliminary stage of building it ( I have attached the file and some of you may have seen it before). 
      What I want to do is, have all my files in the database with random names and list them based on their characteristics. I want to do that in my application in the place of 'file' box. So that I can click on the file and run it (double-click on the file in application to make them work in active file). based on the parameters listed on the database I want to filter them to find any specific file. How the interface of database should look like is shown blow (Image) . 
      It doesn't have to be a real database, just a directory application. I am trying to make it without the database toolkit.  If anyone can help me out and guide me out or guide me in the right direction then that would be great. Thanks. 

      Multicolumn list box v1.5.vi
    • By Paul Liu
      Hi All,
      I am a new user to LabView and this is my first project using it. The project requires me to read a massive spreadsheet from Excel into LabView and then allowing the user to do the following:
      - Select which columns to plot against the first column
      - Use a cursor to select a portion of the spreadsheet: the Vi will then average the selected data by column (in other words, if the user selects data across multiple columns, the program will average data in each column separately). Then write the averages to the csv file.
      So far, I have the spreadsheet read into a table as strings (because the first row of the spreadsheet is words). I have spent a lot of time searching how to allow the user to select data on the table to perform operations on, but to no avail. I am hoping you guys could give me some insight on how to tackle this project.
    • By Hack4Life
      Hello,
      I need to select a .csv file which has two integers seperated through a comma per line. I have to sume these to values and write it to a new .csv file with the two integers and as third position the result. I have a path selector and a read from spreadsheet and a write to spreadsheet element. But I do not know how to read the two values line per line and add those to values with the result in a new .csv file. 
       
      For example:
      input:
      A,B 1,3 2,6 3,3 output:
      A,B,C 1,3,4 2,6,8 3,3,6 I hope that somebody can help me.
       
      Thanks for your help!
      Greets from Austria,
      Fabian
×
×
  • Create New...

Important Information

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