Skip to content

Commit

Permalink
remove empty space from csv
Browse files Browse the repository at this point in the history
  • Loading branch information
lauracosta committed May 20, 2024
1 parent 839976f commit b60e417
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions waterTable/importData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bool loadCsvRegistry(QString csvRegistry, std::vector<Well> &wellList, QString &
wrongLines++;
continue;
}
items[posId] = items[posId].simplified();
QString id = items[posId].remove(QChar('"'));
if (idList.contains(id))
{
Expand All @@ -49,13 +50,15 @@ bool loadCsvRegistry(QString csvRegistry, std::vector<Well> &wellList, QString &
continue;
}
idList.append(id);
items[posUtmx] = items[posUtmx].simplified();
double utmX = items[posUtmx].remove(QChar('"')).toDouble(&ok);
if (!ok)
{
errorList.append(id);
wrongLines++;
continue;
}
items[posUtmy] = items[posUtmy].simplified();
double utmY = items[posUtmy].remove(QChar('"')).toDouble(&ok);
if (!ok)
{
Expand Down Expand Up @@ -115,6 +118,7 @@ bool loadCsvDepths(QString csvDepths, std::vector<Well> &wellList, int waterTabl
wrongLines++;
continue;
}
items[posId] = items[posId].simplified();
QString id = items[posId].remove(QChar('"'));
bool found = false;
int index = NODATA;
Expand All @@ -134,15 +138,15 @@ bool loadCsvDepths(QString csvDepths, std::vector<Well> &wellList, int waterTabl
wrongLines++;
continue;
}

items[posDate] = items[posDate].simplified();
QDate date = QDate::fromString(items[posDate].remove(QChar('"')),"yyyy-MM-dd");
if (! date.isValid())
{
errorList.append(line);
wrongLines++;
continue;
}

items[posDepth] = items[posDepth].simplified();
int value = items[posDepth].remove(QChar('"')).toInt(&ok);
if (!ok || value == NODATA || value < 0 || value > waterTableMaximumDepth)
{
Expand Down

0 comments on commit b60e417

Please sign in to comment.