943,772 Members | Top Members by Rank

Ad:
Mar 4th, 2009
0

Reading CSV Files

Expand Post »
My project needs to read records from a CSV file. The file contains 3 columns of data. Record is continuously being appended to the file by another application (about once every 6-8 seconds), and my application is to read the records and store the new ones.

I am currently opening the file, reading the entire contents row by row using a Input # statement, checking if the record has already been stored and storing the new ones. This is making the process unacceptably slow.

Is there a way by which I could skip to the position where I finished the last reading and continue from there ?
Similar Threads
Reputation Points: 20
Solved Threads: 10
Junior Poster
aparnesh is offline Offline
193 posts
since Jul 2005
Mar 4th, 2009
0

Re: Reading CSV Files

There are a couple of ways to solve this but first question is...
does the other program create the file if it is not there?

If so, you could wait until you have exclusive access to the file and once you do you could do a couple of different things. First you could name the file a different name and allow the other program to create a new file and continue on with its operations while you leisurly open the other file, read in its contents, and then delete it.

If the other program does not create the file if it is not there then, once again wait until you can get exclusive access to the file, rename it, then rename a blank file to replace it while you take your time once again.

Now, if you can never get exclusive access to the file, then you could keep track of how many bytes you have read in and each time you access the file (binary random access), you could jump to that position or you could remember how many lines you have read in and before you start comparing you could read in that many lines + or - 1 or exact, however you want. Then start comparing and adding.

Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Kkeep same format after converting to .csv
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Target a web link, help me please.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC