Skip to content

Commit 39cfafc

Browse files
committed
handle quoted values in CSV parser logic
1 parent 86733a8 commit 39cfafc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/AdafruitIO_Data.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,19 @@ char* AdafruitIO_Data::charFromDouble(double d, int precision)
413413

414414
bool AdafruitIO_Data::_parseCSV()
415415
{
416-
// parse value from csv
417-
strcpy(_value, strtok(_csv, ","));
416+
char *csv = _csv;
417+
418+
if(csv[0] == '"') {
419+
// handle quoted values
420+
csv++;
421+
int end = strstr(csv, "\",") - csv;
422+
strncpy(_value, csv, end);
423+
csv += (end + 2);
424+
} else {
425+
// handle normal values
426+
strcpy(_value, strtok(csv, ","));
427+
}
428+
418429
if (! _value) return false;
419430

420431
// parse lat from csv and convert to float

0 commit comments

Comments
 (0)