Reading file from SD card

Hi, im trying to read the data from an SD card but i dont think im grasping how to go about it.

I am at the point where my arduino see's the card, finds the text file and opens it all ok, but its the next bit i cant get. The textfile has one line of seperated numbers and i want to load them into varaiables? How do i do this?

Do i first need to load all the file data into a buffer? I cant work out how to read data from the file at a certain point in the file?

Ive done alot of googling but not found alot, theres plenty on getting to the point where i am, and plenty of simply streaming the data to the serial ,but not how to store it?

Thanks Andy

Do i first need to load all the file data into a buffer?

Yes, that is the easiest way.

I cant work out how to read data from the file at a certain point in the file?

Why do you need to? You said that the file contains 1 record. Presumably, you want to read the entire record, one character at a time.

If there is a reason to read from a specific point, the seek() method lets you define that point.

Ive done alot of googling but not found alot, theres plenty on getting to the point where i am, and plenty of simply streaming the data to the serial ,but not how to store it?

You store it just like you would serial data. How to do THAT comes up nearly every day on the forum.

Hi Paul, thanks for helping out again. if I explain more you might be able to put in the right direction.

What I'm trying to do is have some values Stored in the epprom that are used with the software. And at some point these epprom values might need changing, which is where the sd card comes in. Beginning of the software it checks for an sd card and text file and then hopefully reads the values and updates the epprom.

So I'm at the bit where it reads the file contents, what do I use as a buffer? And char array? Can this be declared as an unknown size? Next How do I read char by char?

Thanks Andy

what do I use as a buffer?

A char array.

Can this be declared as an unknown size?

No. You need to have some idea what the data looks like, and size the array to hold the longest realistic set of data.

Next How do I read char by char?

Every call to File.read() reads the next character. Each time you successfully read a character, store the character at the next position in the array, increment the index, and store a NULL at the index position.