I highly suggest checking out this YouTube video (https://www.youtube.com/watch?v=5v5A3j7Rrco), especially around 21:30. It goes over in detail to do exactly what you are asking for, mainly the headings with IDs for each data point. At the end of the day you are going to need something that looks similar to this:
float id = 0; //used to provide a numbered ID to each data point
void setup(){
//initialize all your once-run variables and such
}
void loop(){
//Write Log File Header
File logFile = SD.open("NAME.csv", FILE_WRITE);
if (logFile){
logFile.println(", , , ,"); //Just a leading blank line, incase there was previous data
String header = "ID, Time, Light, Temp"; //These will be the headers for your excel file, CHANGE "" to whatevr headers you would like to use
logFile.println(header);
logFile.close();
Serial.println(header);
}
else {
Serial.println("Couldn't open log file");
}
}
}
This is all code that I currently use to do the exact same thing as you, and its a small edit from what Jeremy Blum does in the YouTube video I just linked you too. This is how the header files will look on an excel sheet, I took a screenshot of an actual file I have created using this method: