Reading a semi-colon separated file from SD card to array

Hi everyone,
having some trouble with reading a semi-colon separated excel file into an array. I'm not very familiar with the SD library. The file I want to read is saved on the SD card as "transform.csv" and below is an excerpt from it:

9.672420769;11.39598823;12.83590056;13.17985002;13.53076854;12.66327068;13.39000871

There are 512 values in the file.

How would I separate the floating-point numbers and save them into an array?

Have a look at the parse example in serial input basics. It assumes the separator is a comma, but you could easily change that to a semi-colon.

...R

How would I separate the floating-point numbers and save them into an array?

Read the file character by character, putting each one you read into an array of chars until you read a semi-colon then add a '\0' to the end of the array to terminate the string. Convert the array of chars into a float using the atof() function and put the result in your target array, but expect to lose some precision in doing so. Keep doing this until you reach the end of the file.

The SD library comes with examples of reading from the SD card.

An array of 512 floats is going to take a lot of memory. Which Arduino are you planning to use ?

Thanks for the replies, very helpful.

You won't have room to store 512 floats on an Uno, it has only 2k of RAM.

Need a '1284P, 16K of SRAM.
One of several form factors I offer:
http://www.crossroadsfencing.com/BobuinoRev17/

In case someone else has the same issue, I have used the following code, which worked quite well for me.

  String inString = ""; 
  float myArray[512]; 



  SDcard = SD.open("TEST.CSV");
  int i=0;
  while (SDcard.available() > 0) {
    int inChar = SDcard.read();
    if (inChar != ';') { 
      inString += (char)inChar;
    }
    else {
      myArray[i] = inString.toFloat();
      i++;
      inString = "";
    }
  }
  SDcard.close();