Forum Discussion

dbattaglia's avatar
dbattaglia
Contributor
11 years ago

What is the most efficient way to retrieve values from a text file?

I have a CSV text file from which I need to retrieve values in a particular column.

Many of the key/id values will be repeated, and for each record having a matching key/id I will need to store a related value in a different column.

 

For example:

id,description,amount,date

12345,yellow crayon,1.25,5/25/2015

3412,green crayon,1.05,5/5/2015

12345,orange crayon,.75,5/10/2015

92355,blue crayon,2.75,5/13/2015

3412,yellow crayon,1.02,5/7/2015

 

Suppose I need to find the sum of amount column for id 12345.

 

I can think of a couple ways to try this, but am wondering if anyone can advise regarding the most efficient way to read the file and retrieve the values.

 

Thanks in advance!

2 Replies

    • dbattaglia's avatar
      dbattaglia
      Contributor

      Sort of, thanks K!

       

      I have used the aqFile and aqTextFile objects, and some others.  I am hoping for some feedback on fast effficient methods that others have tried.

       

      For example, is it more efficient to use ReadWholeTextFile and then parse through the string or to use ReadLine?

       

      I was hoping to save a little time trialing different approaches.

       

      I will test out a couple things and report back.

       

      If you have any suggestions, please share.

       

      Thanks,

      Daniel