Count number of entries on SD card file (fixed but feedback is appreciated)

Hi all,

Ive managed to cobble a simple GPS datalogger together which records Latitude, Longitude and time in a CSV file on an SD card using the standard SD library. Each entry ends with a CR and LF. How does one go about counting the total number of entries on the SD card?

Any help is very much appreciated


EDIT: Managed to get it to work using the following code in setup():

File dataFile ="gpsdata.csv");
if (dataFile) {
  while (dataFile.available()) {
    char cardChar =;
    if (cardChar == '\n') {