read a line in a text file without loading entire file

Just starting out? Need help? Post your questions and find answers here.
mchael
User
User
Posts: 15
Joined: Mon Oct 14, 2019 7:31 am

read a line in a text file without loading entire file

Post by mchael »

Is there a way with purebasic to read a specific line of a file without reading the whole file? Seek and read the part of the file with a specific line?
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: read a line in a text file without loading entire file

Post by infratec »

Of course. But it is slower.
Simply use ReadString() for n times.

Fast it is only possible if all lines have the same length.
Then you can use FileSeek() to jump the right location.
mchael
User
User
Posts: 15
Joined: Mon Oct 14, 2019 7:31 am

Re: read a line in a text file without loading entire file

Post by mchael »

thank you

yes each line is same memory size so fileseek is useful.
Post Reply