How to read number values from a SD card?

Hello, i'm using arduino DUE and have the following problem:

I'm storing 18 values of a sensor calibration in a SD card that are betwen 0-250. I'm using SD.println(value); to send the values to the SD, so the data looks like this:

15
18
117
...etc.

When I power off and back on arduino, I need to be capable of reading those values from the SD and storage them in an array so I don't have to calibrate again the sensor.
It has to be an array beacuse I have to determinate wich index corresponds to each variable.
The problem is that I don't know how to read all the lines in the dataFile and storage them in the array;

I have been reading this post:
https://forum.arduino.cc/index.php?topic=127073.0

But I still don't understand how to do it. I understand that I have to make 2 arrays, one of chars and another of long or int and read the file, storage the info in the char array and then convert that to the int array.

What PaulS said:

PaulS:
You read data from the SD card just like from the serial port - one character at a time. Read and store that data in an array, until you encounter the carriage return. Keep the array NULL terminated, or append a NULL at the end. Then, call atoi() or atol(). Then, reset the array index and read the next set of characters.

PaulS:
You need two arrays - a char array and a long (not int) array.

Read the characters from the file, storing them in the char array, until you encounter a carriage return or line feed.

When you encounter one, call atol() to convert the char array to a long, and store that in the long array.

Reset the char array and index and continue reading.

But it would be great if someone could give an example on how to do it.

I try this for one number at a time:

char fileStr[] = "987654"; // example of what is in the file

char result[7]; // value are between 0/999940? so lenght is 6 characters + 1 ('\0')
uint8_t i = 0; // a counter

while (fileStr[i] != '\0' && i < sizeof(result) - 1) // while character isn't the string terminator
{
 result[i] = fileStr[i]; // store character in result
 i++; // increase counter
}
result[i] = '\0';

unsigned long number = atol(result); // convert result string to numeric value
Serial.print(number); // print the number

But I don't know how to replace the example

char fileStr[] = "987654"; // example of what is in the file

with the actual data of the file.

Again, if someone could give an example on how to read the 18 values that are stored like strings and then convert them into ints in a new array and not only say what I have to do I would be gratefull.

Thanks a lot.

Have you consulted the file functions (with examples) of the SD library, so that you know how to open/read/write/close a file? They are documented.

aarg:
Have you consulted the file functions (with examples) of the SD library, so that you know how to open/read/write/close a file? They are documented.

Yes I have, and for the writing part I don't have problems. I can open/write/close the file, but in the examples for reading the file they don't show how to do what I'm asking, they show how you can Serial print the data of the sd, no how to read line by line and storage it in variables.

Almost anything you can do to Serial you can do to a file. That includes file.parseInt() to read the next integer from the file.

Have you thought of using EEPROM for your calibration data? It's built in.