This would be a bit easier if we knew exactly how you are saving records to the SD card to know how to parse the file. So, without that knowledge, I'll just have to speak on general terms.
Since you are writing to a SD card I'll assume you already know the reference page for the SD Library. Let me highlight some functions that you will want to read up on: [
](SD - Arduino Reference), [
](SD - Arduino Reference), and [
](SD - Arduino Reference).
When you open a file object one of it's properties is a read/write pointer (or can be called a cursor). Some programming languages use two pointers, a read pointer and a write pointer. With the SD library we only have one pointer that does both jobs (I'm not totally clear if the reason is because of how the SD library was written, or if that is how C/C++ deals with file classes, but that level of detail really doesn't matter.) So one needs to remember to move the pointer to the end of the file before writing to avoid overwriting parts of the file.
When the last time your Arduino was on and writing to the data file it may have recorded lots of records. One should expect to find 0 to [very large number] of records. Think of the records as pages in a book. If you just want to know what is on the last page of the book do you start reading from the beginning, or do you turn to the last page? Reading the whole thing might be feasible if the "book" was a short 4-page menu, but what if it is the Oxford English Dictionary? Would you really read through all 12 volumes (for OED1) just to look at the last page? Unfortunately, there the analogy starts to break apart. One can't simply turn to the last saved record in the file. But one can turn to the last byte in the file using
[i]file.[/i]seek(pos). One knows where that last byte is by using
[i]file.[/i]size(), and one can see what that last byte is without moving the read/write pointer by using
[i]file.[/i]peek(). Then it is a simple exercise of scanning backwards from the end of the file looking for your record separator (if you used
[i]file.[/i]println() when writing to the file your separator would be , but since you can only scan one byte at a time, just scan for the character.) Then read and parse the end of the file much like one would read and parse the same data coming in over the serial port (except instead of using
Serial.read() you would use
Hmmm... I suppose one could modify the analogy to fit the exercise better... Think about what you would do if you wanted to read the last chapter of Harry Potter and the Order of the Phoenix? Do you start flipping through pages from the front of the book, or start flipping pages backwards from the last page (page 870 of the US printing)? (I'm ignoring the possibility of a table of contents...)
Remember to put error corrections in there. Like consider what to do if the file isn't found, if the SD card isn't found, what to do if the last record isn't complete or is corrupted, etc.
My suggestion would be to write it as a function that you only call from setup(). That would keep the clutter down in setup(), and allow using local variables in the function that will cease to exist (and thus stop consuming valuable RAM) once the function completes. The 4 bytes of the unsigned long that you will be using to keep tabs of and manipulate the read/write counter should be a local variable, I'm sure there will be others...
Hopefully this is enough for you to cobble together some code that you can then post for us to critique. Not all of us are very tolerant of massive amounts of hand-waving.