Good afternoon everyone, I'm having a problem by trying to erased the fist string line after reading it.
I have a a text file name "1 hour.txt" which it stores some codes like this ones:
1H234
1H343
1H766
What I'm trying to do is read the first line and print it to the serial monitor after reading I want to remove the line and make a file size smaller. I don't if is clear enough.
So far I can only read the first line but I'm stuck with removing bytes from the text.
Thanks!!!
fredi11:
Good afternoon everyone, I'm having a problem by trying to erased the fist string line after reading it.
I have a a text file name "1 hour.txt" which it stores some codes like this ones:
1H234
1H343
1H766
What I'm trying to do is read the first line and print it to the serial monitor after reading I want to remove the line and make a file size smaller. I don't if is clear enough.
So far I can only read the first line but I'm stuck with removing bytes from the text.
Thanks!!!
Welcome to the Arduino forum.
I have not use an SD card with an Arduino. Can we assume that is what you are doing? You did not say.
You can't actually do what you want without copying the entire remainder of the file data to a new file.
But you can decide on a byte value that you can always ignore in your program and let that value work the same as if you had deleted the line.
Your program would "seek" the beginning of the line. If it's the first line in the file, then the seek(0) will position you at the beginning of the file. Then "write" the byte you have chosen to be the "deleted" value for the number of bytes in your first line. Remembering your "line" may also include a "cr" and "lf" at the end.
I don't know if posting my code will work out better so you can understand it.
With this code I can read the first line and print it to the serial monitor.