Hi folks,
Yes, this might sound like a newbie question but there's a TWIST! (And i've done an SO search already...)
I'm trying to read in multiple files, one at a time ... while each file is possibly getting new data APPENDED to the end of it.
I always know the last character position i was last at.
So when I get to a file, I'm thinking I want to read from start position to current end position at the time that line of code was executed?
Then parse all that data.. and goto the next file. While I was parsing that data, it's possible NEW data was appended to the end of the file .. which I will not get to until i come back around and start parsing the file again.
I have around 300-400 files to parse .. which is why I don't particularly want to make shit loads of threads and each thread has it's own db connection, etc. whatever..etc.
Lastly, the new data is not THAT much, per second. so it's not like i'll never 'catch up'.
So .. any ideas how to best do this?
I was also parsing each 'line' .. where a line is a bit of text ended by a '\n', etc.
Thoughts?
Updates / ReEdits..
- Don't worry about the fact i've got many files and want to store the data into a database. The reason I suggested that was so people didn't start giving suggestions to use multiple threads per file, file watchers, etc...
- Each log file has the same structure, etc. just different data/content. And no, I don't want to detect when they have been updated. I just want to manually parse each one, from the last stream position to the current end position.