mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Special handling of Seaber CSV files
These files contain a bit of extra data before the actual CSV part, so we need to skip there to show sensible information to users. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
cbab6cc9c8
commit
c1f716614f
1 changed files with 22 additions and 0 deletions
|
@ -359,6 +359,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
|
|||
QStringList currColumns;
|
||||
QStringList headers;
|
||||
bool matchedSome = false;
|
||||
bool seabear = false;
|
||||
|
||||
// reset everything
|
||||
ColumnNameProvider *provider = new ColumnNameProvider(this);
|
||||
|
@ -369,6 +370,10 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
|
|||
|
||||
f.open(QFile::ReadOnly);
|
||||
QString firstLine = f.readLine();
|
||||
if (firstLine.contains("SEABEAR")) {
|
||||
seabear = true;
|
||||
firstLine = "Time;Depth;NDT;TTS;Ceiling;Temperature;Pressure";
|
||||
}
|
||||
QString separator = ui->CSVSeparator->currentText() == tr("Tab") ? "\t" : ui->CSVSeparator->currentText();
|
||||
currColumns = firstLine.split(separator);
|
||||
if (triggeredBy == INITIAL) {
|
||||
|
@ -449,6 +454,23 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
|
|||
|
||||
f.reset();
|
||||
int rows = 0;
|
||||
|
||||
/* Skipping the header of Seabear CSV file. */
|
||||
if (seabear) {
|
||||
/*
|
||||
* First set of data on Seabear CSV file is metadata
|
||||
* that is separated by an empty line (windows line
|
||||
* termination might be encountered.
|
||||
*/
|
||||
while (strlen(f.readLine()) > 2 && !f.atEnd());
|
||||
/*
|
||||
* Next we have description of the fields and two dummy
|
||||
* lines. Separated again with an empty line from the
|
||||
* actual data.
|
||||
*/
|
||||
while (strlen(f.readLine()) > 2 && !f.atEnd());
|
||||
}
|
||||
|
||||
while (rows < 10 || !f.atEnd()) {
|
||||
QString currLine = f.readLine();
|
||||
currColumns = currLine.split(separator);
|
||||
|
|
Loading…
Add table
Reference in a new issue