Hi
Is it possible to access directly a given line of a file stored in SPIFFS, I mean without reading all the lines before from the beginning of the file ? Thanks
Directly read n-th line in a file in SPIFFS
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: Directly read n-th line in a file in SPIFFS
Not without help (and it's generally impossible, independent on the file system). Only way would be to index a file first, that is, scan through it and record at which position in the file every line begins, so you can later refer to that info and immediately go to the correct position.
Re: Directly read n-th line in a file in SPIFFS
Thanks for your answer. I think this is exactly my case.
My file would be made of several lines (around 2000) each of which is made of 197 bytes.
So it's easy to know the exact place of each lines.
How can I then access for example the 200th line?
My file would be made of several lines (around 2000) each of which is made of 197 bytes.
So it's easy to know the exact place of each lines.
How can I then access for example the 200th line?
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: Directly read n-th line in a file in SPIFFS
I think you would use myfile.seek(line_number*197) to go to the correct position then.
Re: Directly read n-th line in a file in SPIFFS
Thanks. Which library does this? LittleFS, SPIFFS?
Edit: Never mind, it seems it exists in both...
Thanks again, and Happy New Year!
Edit: Never mind, it seems it exists in both...
Thanks again, and Happy New Year!
Who is online
Users browsing this forum: No registered users and 116 guests