Parsing data from CSV file

Hi, i try to get datas from a CSV file on SD Card.

the problem is that i'm trying to locate the "," character, to get field before and after.

For now, the error is : "Request for member 'indexOf' in 'buffer', which is a non class type 'char[90]
on ligne 41
I'm not understanding the error, please could you give me the issue ?

Thanks

#include <SdFat.h>

// SD chip select pin
const uint8_t chipSelect = 53;

// file system object
SdFat sd;

// create a serial stream
ArduinoOutStream cout(Serial);

void testGetline() {
 const int line_buffer_size = 90;
 char buffer[line_buffer_size];
 char Suffix, Command, Angle, DAngle;
 float Coor_X, Coor_Y, Dep_X, Dep_Y, Long_Stitch;
 
 ifstream sdin("TURTLE.CSV");
 int line_number = 0;

 while (sdin.getline(buffer, line_buffer_size, '\n') || sdin.gcount()) {
    int count = sdin.gcount();
    if (sdin.fail()) {
      cout << "Partial long line";
      sdin.clear(sdin.rdstate() & ~ios_base::failbit);
    } else if (sdin.eof()) {
      cout << "Partial final line";  // sdin.fail() is false
    } else {
      count--;  // Don’t include newline in count
      cout << "Line " << ++line_number;
    }
 cout << buffer << endl;
 int Flag1 = buffer.indexOf(',');               // Flag after the suffix
 int Flag2 = buffer.indexOf(',', Flag1 + 1);    // Flag after the Command
 int Flag3 = buffer.indexOf(',', Flag2 + 1);    // Flag after the Coord_X
 int Flag4 = buffer.indexOf(',', Flag3 + 1);    // Flag after the Coord_Y
 int Flag5 = buffer.indexOf(',', Flag4 + 1);    // Flag after the Dep_X
 int Flag6 = buffer.indexOf(',', Flag5 + 1);    // Flag after the Dep_Y
 int Flag7 = buffer.indexOf(',', Flag6 + 1);    // Flag after the Long_Stitch
Serial.println (buffer);
Serial.print ("Positions: ";
Serial.print (Flag1);
Serial.print (" / ");
Serial.print (Flag2);
Serial.print (" / ");
Serial.print (Flag3);
Serial.print (" / ");
Serial.print (Flag4);
Serial.print (" / ");
Serial.print (Flag5);
Serial.print (" / ");
Serial.print (Flag6);
Serial.print (" / ");
Serial.println (Flag7);
delay (500);
  }
}
//------------------------------------------------------------------------------
void setup(void) {
  Serial.begin(9600);
  while (!Serial) {}  // wait for Leonardo

  // pstr stores strings in flash to save RAM
  cout << pstr("Type any character to start\n");
  while (Serial.read() <= 0) {}
  delay(400);  // catch Due reset problem

  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  // breadboards.  use SPI_FULL_SPEED for better performance.
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();

    testGetline();
  cout << "\nDone!\n";
}
//------------------------------------------------------------------------------
void loop(void) {}

Your char buffer[] is not a String here, but a char array. The indexof() method is not suitable for this type of object. With a char []. you're going to have better luck with strchr() and/or strtok().

http://ds.tuxgraphics.org/common/src2/article09043/avr-libc-user-manual-1.6.4/group__avr__string.html#g4a03589020c79fa0b93673634bef711b
http://ds.tuxgraphics.org/common/src2/article09043/avr-libc-user-manual-1.6.4/group__avr__string.html#g6ace85338eafe22a0ff52c00eb9779b8

This demo includes an example for parsing CSV data.

...R