Mercurial > hg > svcore
diff data/fileio/CSVFormat.cpp @ 631:3a5ee4b6c9ad
* Complete the overhaul of CSV file import; now you can pick the purpose for
each column in the file, and SV should do the rest. The most significant
practical improvement here is that we can now handle files in which time
and duration do not necessarily appear in known columns.
author | Chris Cannam |
---|---|
date | Mon, 19 Jul 2010 17:08:56 +0000 |
parents | 11a664058dd8 |
children | ad7c96620886 |
line wrap: on
line diff
--- a/data/fileio/CSVFormat.cpp Fri Jul 16 16:51:39 2010 +0000 +++ b/data/fileio/CSVFormat.cpp Mon Jul 19 17:08:56 2010 +0000 @@ -39,9 +39,7 @@ { m_modelType = TwoDimensionalModel; m_timingType = ExplicitTiming; - m_durationType = Durations; m_timeUnits = TimeSeconds; - m_behaviour = QString::KeepEmptyParts; m_maxExampleCols = 0; m_columnCount = 0; @@ -186,10 +184,6 @@ void CSVFormat::guessPurposes() { - while (m_columnPurposes.size() <= m_columnCount) { - m_columnPurposes.push_back(ColumnUnknown); - } - m_timingType = CSVFormat::ImplicitTiming; m_timeUnits = CSVFormat::TimeWindows; @@ -229,7 +223,6 @@ if (timingColumnCount == 2 && m_timingType == ExplicitTiming) { purpose = ColumnEndTime; - m_durationType = EndTimes; } } } @@ -242,7 +235,7 @@ } } - m_columnPurposes[i] = purpose; + setColumnPurpose(i, purpose); } int valueCount = 0; @@ -281,12 +274,16 @@ } } - if (valueCount == 0) { - m_modelType = OneDimensionalModel; - } else if (valueCount == 1) { - m_modelType = TwoDimensionalModel; + if (timingColumnCount > 1) { + m_modelType = TwoDimensionalModelWithDuration; } else { - m_modelType = ThreeDimensionalModel; + if (valueCount == 0) { + m_modelType = OneDimensionalModel; + } else if (valueCount == 1) { + m_modelType = TwoDimensionalModel; + } else { + m_modelType = ThreeDimensionalModel; + } } std::cerr << "Estimated column purposes: "; @@ -297,8 +294,33 @@ std::cerr << "Estimated model type: " << m_modelType << std::endl; std::cerr << "Estimated timing type: " << m_timingType << std::endl; - std::cerr << "Estimated duration type: " << m_durationType << std::endl; std::cerr << "Estimated units: " << m_timeUnits << std::endl; } +CSVFormat::ColumnPurpose +CSVFormat::getColumnPurpose(int i) +{ + while (m_columnPurposes.size() <= i) { + m_columnPurposes.push_back(ColumnUnknown); + } + return m_columnPurposes[i]; +} +CSVFormat::ColumnPurpose +CSVFormat::getColumnPurpose(int i) const +{ + return m_columnPurposes[i]; +} + +void +CSVFormat::setColumnPurpose(int i, ColumnPurpose p) +{ + while (m_columnPurposes.size() <= i) { + m_columnPurposes.push_back(ColumnUnknown); + } + m_columnPurposes[i] = p; +} + + + +