There is a possibility to read a file from a certain line?
I read a big file with 1000000 of lines.
If I want to store the data of 500000 line to the last line. I need to open the file and read through until you reach the 500000 line where I'm going to start storing the data? Or I can read from the line 500000?
Read from a certain line
Page 1 of 14 Replies - 304 Views - Last Post: 11 July 2012 - 10:35 AM
Replies To: Read from a certain line
#2
Re: Read from a certain line
Posted 10 July 2012 - 04:58 PM
If you don't start from the beginning and read until line 500000, how will you know where line 500000 is? Unless the lines have a constant size, in which case you could use File.seek to move to the correct position, you will have to open the file and look for the 500000'th new-line to discover the correct spot to start reading from.
#3
Re: Read from a certain line
Posted 10 July 2012 - 05:09 PM
Atli, on 10 July 2012 - 04:58 PM, said:
If you don't start from the beginning and read until line 500000, how will you know where line 500000 is? Unless the lines have a constant size, in which case you could use File.seek to move to the correct position, you will have to open the file and look for the 500000'th new-line to discover the correct spot to start reading from.
That is my question. I think there's no way.
#4
Re: Read from a certain line
Posted 10 July 2012 - 08:29 PM
The first line is any and all text before the first new line character. The second line is all the text after the first new line and before the second one. Thus the 500000 line is the text between the 499999 new line char and the 500000 one. It's pretty much an iterative problem.
#5
Re: Read from a certain line
Posted 11 July 2012 - 10:35 AM
atraub, on 10 July 2012 - 08:29 PM, said:
The first line is any and all text before the first new line character. The second line is all the text after the first new line and before the second one. Thus the 500000 line is the text between the 499999 new line char and the 500000 one. It's pretty much an iterative problem.
OK. Thanks
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|