how to read text from sd card, split string and integer?

i want read the sd card text file. In that text file contain name and age of different persons. i want to read that names and their respective age should store in variable.

txt file will be like this:

aaaa:29
bbbb:23
cccc:32
dddd:43
.
.
.
.
so on…

Please give some programming suggestion

thanks in advance…

I’d use a fixed structure to make it easy to pic a random ‘person number x’ (using seek())
That said:
The code below is NOT tested !!

#include <SPI.h>
#include <SD.h>

# define cs_pin_numer 4 // your cs-pin
File persons;

char Name[10];
byte Age, pos;
char ch;

void setup() {
  Serial.begin(9600);
  while (!Serial) ;
  SD.begin(cs_pin_numer); //assumes all OK, file structure is perfect
  persons = SD.open("your_file.txt");
  while (persons.available())
  {
    // read chars to name until a colon is found
    ch = persons.read();
    if (ch == 10 or ch == 13) continue; // CR LF to be skipped
    Name[pos] = ch;
    if (ch != ':') {
      pos++;
      continue;
    }
    Name[pos] = '\0'; // mark 'end of this name'
    pos = 0; // just prepare for 'next' person
    // now age.. two chars !!! (must be altered if this is not true)
    Age = persons.read() - '0';
    Age = Age * 10 + persons.read() - '0';
    // print out Name and age
    // get next on row
  }
  persons.close();
}

void loop()
{
}