However, if you still want to start parsing data out of a SPIFFS file, here is an example:
You hand the function a SPIFFS file handle (in your case 'file' ) a character buffer and its length.
You call the function for each line you want to read.
Maybe you can pick something out of this:
bool ICACHE_FLASH_ATTR getTokenFromStream( File inFile, char * outBuf, const uint16_t bufLen ) {
// for input files with lines terminated with new line.
// get a single token from the input line and then discard the entire line including the '\n'
enum inState_t { start = 1 , inToken = 2 , end = 3 } ;
inState_t inState = start ;
uint16_t bufIndex = 0 ;
for ( ; ; ) {
if ( ! inFile.available() ) break ;
char c = inFile.read() ;
if ( c == '\n' ) break ;
bool isWordChar = ( c > 0x20 && c <= 0x7E ) ; // printable, not space
if ( bufIndex >= ( bufLen - 1 ) ) inState = end ;
else if ( inState == start && isWordChar ) {
inState = inToken ;
outBuf[ bufIndex ++ ] = c ;
}
else if ( inState == inToken && isWordChar ) {
outBuf[ bufIndex ++ ] = c ;
}
else if ( inState == inToken && ! isWordChar ) {
inState = end ;
}
} // end of loop
if ( inState == start ) {
return false ; // nothing found
}
else {
outBuf[ bufIndex] = 0 ;
return true ;
}
}