comparison data/fileio/CSVFileReader.cpp @ 676:611a4fa14dde sv_v1.8

* Avoid including non-value columns in 3d-model column count (fixes #38)
author Chris Cannam
date Mon, 04 Apr 2011 15:20:29 +0100
parents 3a5ee4b6c9ad
children b4a8d8221eaf
comparison
equal deleted inserted replaced
675:341e4e1a6ed3 676:611a4fa14dde
177 size_t startFrame = 0; // for calculation of dense model resolution 177 size_t startFrame = 0; // for calculation of dense model resolution
178 bool firstEverValue = true; 178 bool firstEverValue = true;
179 179
180 std::map<QString, int> labelCountMap; 180 std::map<QString, int> labelCountMap;
181 181
182 int valueColumns = 0;
183 for (int i = 0; i < m_format.getColumnCount(); ++i) {
184 if (m_format.getColumnPurpose(i) == CSVFormat::ColumnValue) {
185 ++valueColumns;
186 }
187 }
188
182 while (!in.atEnd()) { 189 while (!in.atEnd()) {
183 190
184 // QTextStream's readLine doesn't cope with old-style Mac 191 // QTextStream's readLine doesn't cope with old-style Mac
185 // CR-only line endings. Why did they bother making the class 192 // CR-only line endings. Why did they bother making the class
186 // cope with more than one sort of line ending, if it still 193 // cope with more than one sort of line ending, if it still
223 230
224 case CSVFormat::ThreeDimensionalModel: 231 case CSVFormat::ThreeDimensionalModel:
225 model3 = new EditableDenseThreeDimensionalModel 232 model3 = new EditableDenseThreeDimensionalModel
226 (sampleRate, 233 (sampleRate,
227 windowSize, 234 windowSize,
228 list.size(), 235 valueColumns,
229 EditableDenseThreeDimensionalModel::NoCompression); 236 EditableDenseThreeDimensionalModel::NoCompression);
230 model = model3; 237 model = model3;
231 break; 238 break;
232 } 239 }
233 } 240 }
299 306
300 DenseThreeDimensionalModel::Column values; 307 DenseThreeDimensionalModel::Column values;
301 308
302 for (int i = 0; i < list.size(); ++i) { 309 for (int i = 0; i < list.size(); ++i) {
303 310
311 if (m_format.getColumnPurpose(i) != CSVFormat::ColumnValue) {
312 continue;
313 }
314
304 bool ok = false; 315 bool ok = false;
305 float value = list[i].toFloat(&ok); 316 float value = list[i].toFloat(&ok);
306 317
307 if (m_format.getColumnPurpose(i) == CSVFormat::ColumnValue) { 318 values.push_back(value);
308 values.push_back(value);
309 }
310 319
311 if (firstEverValue || value < min) min = value; 320 if (firstEverValue || value < min) min = value;
312 if (firstEverValue || value > max) max = value; 321 if (firstEverValue || value > max) max = value;
313 322
314 if (firstEverValue) { 323 if (firstEverValue) {
315 startFrame = frameNo; 324 startFrame = frameNo;
316 model3->setStartFrame(startFrame); 325 model3->setStartFrame(startFrame);
317 } else if (lineno == 1 && 326 } else if (lineno == 1 &&
318 timingType == CSVFormat::ExplicitTiming) { 327 timingType == CSVFormat::ExplicitTiming) {