Mercurial > hg > svcore
comparison data/fileio/CSVFormat.cpp @ 897:69cc0454ed72
Make it possible to import CSV files directly into Note layers
author | Chris Cannam |
---|---|
date | Mon, 07 Apr 2014 10:47:15 +0100 |
parents | e802e550a1f2 |
children | 1974859baba5 |
comparison
equal
deleted
inserted
replaced
892:451f7f3ab6e7 | 897:69cc0454ed72 |
---|---|
64 // See comment about line endings in CSVFileReader::load() | 64 // See comment about line endings in CSVFileReader::load() |
65 | 65 |
66 QString chunk = in.readLine(); | 66 QString chunk = in.readLine(); |
67 QStringList lines = chunk.split('\r', QString::SkipEmptyParts); | 67 QStringList lines = chunk.split('\r', QString::SkipEmptyParts); |
68 | 68 |
69 for (size_t li = 0; li < lines.size(); ++li) { | 69 for (int li = 0; li < lines.size(); ++li) { |
70 | 70 |
71 QString line = lines[li]; | 71 QString line = lines[li]; |
72 if (line.startsWith("#") || line == "") continue; | 72 if (line.startsWith("#") || line == "") continue; |
73 | 73 |
74 guessQualities(line, lineno); | 74 guessQualities(line, lineno); |
84 | 84 |
85 void | 85 void |
86 CSVFormat::guessSeparator(QString line) | 86 CSVFormat::guessSeparator(QString line) |
87 { | 87 { |
88 char candidates[] = { ',', '\t', ' ', '|', '/', ':' }; | 88 char candidates[] = { ',', '\t', ' ', '|', '/', ':' }; |
89 for (int i = 0; i < sizeof(candidates)/sizeof(candidates[0]); ++i) { | 89 for (int i = 0; i < int(sizeof(candidates)/sizeof(candidates[0])); ++i) { |
90 if (StringBits::split(line, candidates[i], m_allowQuoting).size() >= 2) { | 90 if (StringBits::split(line, candidates[i], m_allowQuoting).size() >= 2) { |
91 m_separator = candidates[i]; | 91 m_separator = candidates[i]; |
92 return; | 92 return; |
93 } | 93 } |
94 } | 94 } |