importing data of a txt file from SD card

Hello everybody,

I'm working on a small project for the university and I'm using arduino mega 2560 and I'm totally new to arduino. What I want to do is the following:

  • I have a txt file (on SD card) which looks like this:
    13.154334 1.656223 - 34.232323 5.234223

34.736546 9.765645 - 75.357563 8.534533

.

.

etc

and I know how many lines does the file have

  • I want to import the data from the file to the mega so i can process them later, but i need them to be seperated....for example like this:
    a(1,1) = 13.154334
    a(2,1) = 34.736546
    b(1,1) = 1.656223
    b(2,1) = 9.765645
    c(1,1) = 34.232323
    c(2,1) = 75.357563
    d(1,1) = 5.234223
    d(2,1) = 8.534533
    .
    .
    etc

I would appreciate it very much if anyone could help me with that
Thank you

use file.parseFloat().

for (int i = 0; file.available(); i++) {
a[i, 0] = file.parseFloat();
a[i, 1] = file.parseFloat();
}

thnx for your comment, however is there any way to determine the number of digits which will be read after the comma within the parse function ?
so that this number 34.736546 for example would be saved as exactly 34.736546 and not as 34.74 ?

MrMajd:
thnx for your comment, however is there any way to determine the number of digits which will be read after the comma within the parse function ?
so that this number 34.736546 for example would be saved as exactly 34.736546 and not as 34.74 ?

it is read exactly.

so that this number 34.736546 for example would be saved as exactly 34.736546 and not as 34.74 ?

If you are seeing 34.74 when printing a float the try

Serial.print(theFloat, 6);  //print the float showing 6 places

Otherwise it defaults to 2 places