SD Card formatting weirdly

Hi,

Random issue annoying me, trying to save sensor data to a sd card,

when I'm saving it in CSV format it saves the first two data points correctly but on the third
it takes a new line. see below images of output and code.

any help would be appreciated.

Regards,
Dav


looks like your var   inputString   has  \n   at the end

try to trim it using

inputString.trim();

or

inputString.replace("\n","");

I assume inputString is of a String type

thank you.

There is no good reason to use Strings with Serial.print. On an AVR you should avoid using Strings entirely, because they cause program malfunctions and outright crashes.