This is a sample of reading and writing a text file saved in an SD card with ESP32.
I couldn't find much simple sample code on the net to read and write, so I drew it.
I used this site as a reference for wiring between the SD card and ESP.
And I used this code as a reference.
Save data to SD card with Arduino
Reference: mgo-tec電子工作