From 5991341e5fbca680a43b67a8ea820b3e6ea528fe Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Sat, 3 Jan 2015 11:02:23 +0000 Subject: [PATCH] Add Peripedal CSV support .. and a test ride too. --- src/CsvRideFile.cpp | 85 +- src/CsvRideFile.h | 2 +- test/rides/peripedal_3min_1.csv | 3622 +++++++++++++++++++++++++++++++ 3 files changed, 3707 insertions(+), 2 deletions(-) create mode 100644 test/rides/peripedal_3min_1.csv diff --git a/src/CsvRideFile.cpp b/src/CsvRideFile.cpp index a51d6f02a..bfdce5fd9 100644 --- a/src/CsvRideFile.cpp +++ b/src/CsvRideFile.cpp @@ -30,6 +30,31 @@ static int csvFileReaderRegistered = RideFileFactory::instance().registerReader( "csv","Comma-Separated Values", new CsvFileReader()); +int static periMonth(QString month) +{ + if (month == "jan") return 1; + if (month == "feb") return 2; + if (month == "mar") return 3; + if (month == "apr") return 4; + if (month == "may") return 5; + if (month == "jun") return 6; + if (month == "jul") return 7; + if (month == "aug") return 8; + if (month == "sep") return 9; + if (month == "oct") return 10; + if (month == "nov") return 11; + if (month == "dec") return 12; + return QDate::currentDate().month(); // no idea +} + +static QDate periDate(QString date) +{ + QStringList parts = date.split("-"); + if (parts.count() == 2) { + return QDate(QDate::currentDate().year(), periMonth(parts[1]), parts[0].toInt()); + } + return QDate::currentDate(); +} static QDate moxyDate(QString date) { QStringList parts = date.split("-"); @@ -93,6 +118,7 @@ RideFile *CsvFileReader::openRideFile(QFile &file, QStringList &errors, QListsetDeviceType("Peripedal"); + rideFile->setFileFormat("Peripedal CSV (csv)"); + unitsHeader = 1; + recInterval = 1; + ++lineno; + continue; } else if(powertapCSV.indexIn(line) != -1) { csvType = powertap; @@ -305,7 +341,7 @@ RideFile *CsvFileReader::openRideFile(QFile &file, QStringList &errors, QList