Coding Question for Data Logging

I am trying to capture temperature measurements with a SD data logger. I want to take the data file and save it as a .csv file so it can be imported into Excel. My problem is with the code below.

void writeDouble(double val) { val = double round(val); long ipart; ipart = (long) val;

dataString += (int(ipart)); //prints the int part dataFile.print(dataString); dataString = (","); dataFile.print(dataString);

} In the loop function it reads the analog pin connect to a thermistor and does the assign. value = Thermistor(sensorValue); It is doing this in a for statement for testing purposes for 30 seconds. With each pass through the for statement it calls the writeDouble function listed above. Everything works fine except that it throw an extra comma after the value. Is there a way to do this without winding up with two commas?

I think your problem is:

  dataString += (int(ipart)); //prints the int part

Try doing an assignment instead of append:

  dataString = (int(ipart)); //prints the int part

You can also simplify:

  dataString = (",");