'Arduino - write highscores to SQLite database on SD card

EDIT since the solution I found took a different path I updated the title to reflect the final solution. The final solution allows to easily add and delete entries or retrieve how many you want with a simple query. The original questio (below) was about solving the problem with a txt file.

I have an ESP32 that currently writes highscores down to the EEPROM.

each entry consists of a name and the score.

I would like to replace this working solution with a SD card. I would have a txt file on the SD card containing the top 100 scores. a file would be like this:

Player1          97.3     ROWCHECKSUM
Some player name 92.3     ROWCHECKSUM
Player1          91.2     ROWCHECKSUM
Player1          90.3     ROWCHECKSUM
Player2          87.1     ROWCHECKSUM
Player4 guy      77.3     ROWCHECKSUM
Player2          64.3     ROWCHECKSUM
Player1          61.1     ROWCHECKSUM
Player7          51.1     ROWCHECKSUM
.
.
.
Player9          21.1     ROWCHECKSUM

the rowchecksum would make sure that nobody changed the file manually. Each time there is a new highscore, I'd have to update the txt file. what would be a good aproach to this? Deleting the file and regenerating it every time? it seems like a lot of data to write just to delete the last row and insert the new one in the proper place.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source