diff data/fileio/CSVFileReader.cpp @ 491:6f8ee19984ad

* When loading data with timestamps in seconds, round each time to its nearest neighbouring frame instead of rounding down * Count from 1 when numbering points loaded from files without labels, rather than 0 (and also when printing errors with line numbers)
author Chris Cannam
date Mon, 24 Nov 2008 12:26:21 +0000
parents 183ee2a55fc7
children 3ccf48fb81d6
line wrap: on
line diff
--- a/data/fileio/CSVFileReader.cpp	Fri Nov 21 18:03:14 2008 +0000
+++ b/data/fileio/CSVFileReader.cpp	Mon Nov 24 12:26:21 2008 +0000
@@ -189,7 +189,7 @@
                     if (timeUnits == CSVFormat::TimeSeconds) {
 
                         double time = numeric.toDouble(&ok);
-                        frameNo = int(time * sampleRate + 0.00001);
+                        frameNo = int(time * sampleRate + 0.5);
 
                     } else {
 
@@ -205,7 +205,7 @@
                             std::cerr << "WARNING: CSVFileReader::load: "
                                       << "Bad time format (\"" << s.toStdString()
                                       << "\") in data line "
-                                      << lineno << ":" << std::endl;
+                                      << lineno+1 << ":" << std::endl;
                             std::cerr << line.toStdString() << std::endl;
                         } else if (warnings == warnLimit) {
                             std::cerr << "WARNING: Too many warnings" << std::endl;
@@ -222,7 +222,7 @@
                 SparseOneDimensionalModel::Point point
                     (frameNo,
                      tidyList.size() > 0 ? tidyList[tidyList.size()-1] :
-                     QString("%1").arg(lineno));
+                     QString("%1").arg(lineno+1));
 
                 model1->addPoint(point);
 
@@ -231,7 +231,7 @@
                 SparseTimeValueModel::Point point
                     (frameNo,
                      tidyList.size() > 0 ? tidyList[0].toFloat() : 0.0,
-                     tidyList.size() > 1 ? tidyList[1] : QString("%1").arg(lineno));
+                     tidyList.size() > 1 ? tidyList[1] : QString("%1").arg(lineno+1));
 
                 model2->addPoint(point);
 
@@ -253,7 +253,7 @@
                             std::cerr << "WARNING: CSVFileReader::load: "
                                       << "Non-numeric value \""
                                       << list[i].toStdString()
-                                      << "\" in data line " << lineno
+                                      << "\" in data line " << lineno+1
                                       << ":" << std::endl;
                             std::cerr << line.toStdString() << std::endl;
                             ++warnings;