Mercurial > hg > svcore
diff data/fileio/CSVFormat.cpp @ 1585:9570ef94eaa3
Add mechanism to retrieve the set of plausible separators found in CSV-like file when guessing its format
author | Chris Cannam |
---|---|
date | Wed, 09 Jan 2019 14:39:50 +0000 |
parents | a92e94215863 |
children | bde22957545e |
line wrap: on
line diff
--- a/data/fileio/CSVFormat.cpp Wed Nov 14 15:46:35 2018 +0000 +++ b/data/fileio/CSVFormat.cpp Wed Jan 09 14:39:50 2019 +0000 @@ -39,8 +39,6 @@ bool CSVFormat::guessFormatFor(QString path) { - m_separator = ""; // to prompt guessing for it - m_modelType = TwoDimensionalModel; m_timingType = ExplicitTiming; m_timeUnits = TimeSeconds; @@ -108,14 +106,12 @@ for (int i = 0; i < candidates.length(); ++i) { auto bits = StringBits::split(line, candidates[i], m_allowQuoting); if (bits.size() >= 2) { - SVDEBUG << "Successfully split the line into:" << endl; - for (auto b: bits) { - SVDEBUG << b << endl; + m_plausibleSeparators.insert(candidates[i]); + if (m_separator == "") { + m_separator = candidates[i]; + SVDEBUG << "Estimated column separator: '" << m_separator + << "'" << endl; } - m_separator = candidates[i]; - SVDEBUG << "Estimated column separator: '" << m_separator - << "'" << endl; - return; } } } @@ -123,9 +119,7 @@ void CSVFormat::guessQualities(QString line, int lineno) { - if (m_separator == "") { - guessSeparator(line); - } + guessSeparator(line); QStringList list = StringBits::split(line, getSeparator(), m_allowQuoting);