mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Detect pipe as field separator in CSV import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7a4fa510e9
commit
375f698c78
1 changed files with 7 additions and 4 deletions
|
@ -347,7 +347,7 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
|
|||
for (int i = 0; !CSVApps[i].name.isNull(); ++i)
|
||||
ui->knownImports->addItem(CSVApps[i].name);
|
||||
|
||||
ui->CSVSeparator->addItems( QStringList() << tr("Tab") << "," << ";");
|
||||
ui->CSVSeparator->addItems( QStringList() << tr("Tab") << "," << ";" << "|");
|
||||
|
||||
loadFileContents(-1, INITIAL);
|
||||
|
||||
|
@ -487,11 +487,14 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
|
|||
int tabs = firstLine.count('\t');
|
||||
int commas = firstLine.count(',');
|
||||
int semis = firstLine.count(';');
|
||||
if (tabs > commas && tabs > semis)
|
||||
int pipes = firstLine.count('|');
|
||||
if (tabs > commas && tabs > semis && tabs > pipes)
|
||||
separator = "\t";
|
||||
else if (commas > tabs && commas > semis)
|
||||
else if (commas > tabs && commas > semis && commas > pipes)
|
||||
separator = ",";
|
||||
else if (semis > tabs && semis > commas)
|
||||
else if (pipes > tabs && pipes > commas && pipes > semis)
|
||||
separator = "|";
|
||||
else if (semis > tabs && semis > commas && semis > pipes)
|
||||
separator = ";";
|
||||
if (ui->CSVSeparator->currentText() != separator) {
|
||||
blockSignals(true);
|
||||
|
|
Loading…
Reference in a new issue