# HG changeset patch # User Chris Cannam # Date 1301926829 -3600 # Node ID 611a4fa14dde377cc8d9778d10bd2b39f197a835 # Parent 341e4e1a6ed3231eec24010a49fec7b127f71f37 * Avoid including non-value columns in 3d-model column count (fixes #38) diff -r 341e4e1a6ed3 -r 611a4fa14dde data/fileio/CSVFileReader.cpp --- a/data/fileio/CSVFileReader.cpp Tue Mar 29 17:55:31 2011 +0100 +++ b/data/fileio/CSVFileReader.cpp Mon Apr 04 15:20:29 2011 +0100 @@ -179,6 +179,13 @@ std::map labelCountMap; + int valueColumns = 0; + for (int i = 0; i < m_format.getColumnCount(); ++i) { + if (m_format.getColumnPurpose(i) == CSVFormat::ColumnValue) { + ++valueColumns; + } + } + while (!in.atEnd()) { // QTextStream's readLine doesn't cope with old-style Mac @@ -225,7 +232,7 @@ model3 = new EditableDenseThreeDimensionalModel (sampleRate, windowSize, - list.size(), + valueColumns, EditableDenseThreeDimensionalModel::NoCompression); model = model3; break; @@ -301,16 +308,18 @@ for (int i = 0; i < list.size(); ++i) { + if (m_format.getColumnPurpose(i) != CSVFormat::ColumnValue) { + continue; + } + bool ok = false; float value = list[i].toFloat(&ok); - if (m_format.getColumnPurpose(i) == CSVFormat::ColumnValue) { - values.push_back(value); - } + values.push_back(value); if (firstEverValue || value < min) min = value; if (firstEverValue || value > max) max = value; - + if (firstEverValue) { startFrame = frameNo; model3->setStartFrame(startFrame); diff -r 341e4e1a6ed3 -r 611a4fa14dde data/fileio/CSVFormat.cpp --- a/data/fileio/CSVFormat.cpp Tue Mar 29 17:55:31 2011 +0100 +++ b/data/fileio/CSVFormat.cpp Mon Apr 04 15:20:29 2011 +0100 @@ -174,11 +174,11 @@ } } - std::cerr << "Estimated column qualities: "; - for (int i = 0; i < m_columnCount; ++i) { - std::cerr << int(m_columnQualities[i]) << " "; - } - std::cerr << std::endl; +// std::cerr << "Estimated column qualities: "; +// for (int i = 0; i < m_columnCount; ++i) { +// std::cerr << int(m_columnQualities[i]) << " "; +// } +// std::cerr << std::endl; } void @@ -286,15 +286,15 @@ } } - std::cerr << "Estimated column purposes: "; - for (int i = 0; i < m_columnCount; ++i) { - std::cerr << int(m_columnPurposes[i]) << " "; - } - std::cerr << std::endl; +// std::cerr << "Estimated column purposes: "; +// for (int i = 0; i < m_columnCount; ++i) { +// std::cerr << int(m_columnPurposes[i]) << " "; +// } +// std::cerr << std::endl; - std::cerr << "Estimated model type: " << m_modelType << std::endl; - std::cerr << "Estimated timing type: " << m_timingType << std::endl; - std::cerr << "Estimated units: " << m_timeUnits << std::endl; +// std::cerr << "Estimated model type: " << m_modelType << std::endl; +// std::cerr << "Estimated timing type: " << m_timingType << std::endl; +// std::cerr << "Estimated units: " << m_timeUnits << std::endl; } CSVFormat::ColumnPurpose