Read CSV or TXT from SD card into string or array

CatweazleNZ:
You can read SD card files line-by-line if this helps:

String l_line = "";

//open the file here
while (l_SDFile.available() != 0) {
   //A inconsistent line length may lead to heap memory fragmentation
   l_line = l_SDFile.readStringUntil('\n');
   if (l_line == "") //no blank lines are anticipated
     break;
   //

//parse l_line here
}
//close the file here





Cheers

Catweazle NZ

Thank You! But some Arduino functions not work with strings created with

.readStringUntil('\n');

function
Because files on SD have "CR" symbol, best way is using

.readStringUntil('\r');

//Sorry, for my bad English

voha888:
Because files on SD have "CR" symbol, best way is using

It depends on the OS and application that wrote the file to SD in the first place. See Newline - Wikipedia.

PS
This thread is old