# HG changeset patch # User Chris Cannam # Date 1484057914 0 # Node ID 1bf38a4b91c4cfd7a77de73fa77a6723f80fe211 # Parent 49b43306778b7440df83321a58c7e71416f59c16 When importing CSV, if the first line doesn't have a separator, continue to leave the separator indeterminate until we arrive at a line that does. Fixes inability to load correctly CSV files in which some lines have more columns than others diff -r 49b43306778b -r 1bf38a4b91c4 data/fileio/CSVFileReader.h --- a/data/fileio/CSVFileReader.h Tue Jan 10 11:08:14 2017 +0000 +++ b/data/fileio/CSVFileReader.h Tue Jan 10 14:18:34 2017 +0000 @@ -13,8 +13,8 @@ COPYING included with this distribution for more information. */ -#ifndef _CSV_FILE_READER_H_ -#define _CSV_FILE_READER_H_ +#ifndef SV_CSV_FILE_READER_H +#define SV_CSV_FILE_READER_H #include "DataFileReader.h" diff -r 49b43306778b -r 1bf38a4b91c4 data/fileio/CSVFormat.cpp --- a/data/fileio/CSVFormat.cpp Tue Jan 10 11:08:14 2017 +0000 +++ b/data/fileio/CSVFormat.cpp Tue Jan 10 14:18:34 2017 +0000 @@ -25,6 +25,8 @@ #include +#include "base/Debug.h" + CSVFormat::CSVFormat(QString path) : m_separator(""), m_sampleRate(44100), @@ -92,7 +94,6 @@ return; } } - m_separator = " "; } void @@ -100,7 +101,7 @@ { if (m_separator == "") guessSeparator(line); - QStringList list = StringBits::split(line, m_separator[0], m_allowQuoting); + QStringList list = StringBits::split(line, getSeparator(), m_allowQuoting); int cols = list.size(); if (lineno == 0 || (cols > m_columnCount)) m_columnCount = cols; @@ -182,11 +183,13 @@ } } -// cerr << "Estimated column qualities: "; -// for (int i = 0; i < m_columnCount; ++i) { -// cerr << int(m_columnQualities[i]) << " "; -// } -// cerr << endl; + if (lineno < 10) { + SVDEBUG << "Estimated column qualities for line " << lineno << " (reporting up to first 10): "; + for (int i = 0; i < m_columnCount; ++i) { + SVDEBUG << int(m_columnQualities[i]) << " "; + } + SVDEBUG << endl; + } } void @@ -314,15 +317,15 @@ } } -// cerr << "Estimated column purposes: "; -// for (int i = 0; i < m_columnCount; ++i) { -// cerr << int(m_columnPurposes[i]) << " "; -// } -// cerr << endl; + SVDEBUG << "Estimated column purposes: "; + for (int i = 0; i < m_columnCount; ++i) { + SVDEBUG << int(m_columnPurposes[i]) << " "; + } + SVDEBUG << endl; -// cerr << "Estimated model type: " << m_modelType << endl; -// cerr << "Estimated timing type: " << m_timingType << endl; -// cerr << "Estimated units: " << m_timeUnits << endl; + SVDEBUG << "Estimated model type: " << m_modelType << endl; + SVDEBUG << "Estimated timing type: " << m_timingType << endl; + SVDEBUG << "Estimated units: " << m_timeUnits << endl; } CSVFormat::ColumnPurpose diff -r 49b43306778b -r 1bf38a4b91c4 data/fileio/CSVFormat.h --- a/data/fileio/CSVFormat.h Tue Jan 10 11:08:14 2017 +0000 +++ b/data/fileio/CSVFormat.h Tue Jan 10 14:18:34 2017 +0000 @@ -13,8 +13,8 @@ COPYING included with this distribution for more information. */ -#ifndef _CSV_FORMAT_H_ -#define _CSV_FORMAT_H_ +#ifndef SV_CSV_FORMAT_H +#define SV_CSV_FORMAT_H #include #include