I have all records divided in many files, each files contain hundred lines with one 8 bytes digit in each line.
How to delete one line from file?
Can not SdFat do it? Now If I want to delete line x, I need to copy all records from first x-1 lines, copy all records from x+1 to n. And store them in new file. Remove current file and make name of new as old name of deleted file.
First some questions:
Q1: How many files are there?
Q2: how many lines per file?
Q3: what are the semantics of the line?
Can somebody tell me more easy way?
depending on the semantics-
mark the line as invalid or with invalid chars (e.g. --------) NB change first digit into * or even better change its ascii value into a byte value ('1' => 1 ) The byte value indicates it is a deleted record but it still can be recovered.
==> Q: can the processing application(s) handle this?
move the last line to the overwritable line (fastest, but only if the order of the numbers is meaningless)
you can "shift all numbers" one line from pos x+1 to the end. No need to rename.
Use a python script on a PC. use the PC's memory as intermediate
WARNING: Note that the infile solutions 1 and 2 have the risk of corruption if it fails
There are many files. About 100 folders with 100 files in each. And each file have about 100 records. One record (line of file) is id, id is 10 bytes number. May be I will separate all numbers with some symbol ("\n" for example).
Using PC for working with files is not suitable for my project. [it is crazy for any project I hope]
The SDfat library has an example LS that can do a recursive walk through the filesystem on the SD disk. Think that can be the basis for your app. instaed of printing you need to call a function that opens the file and rewrite it.