mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#2225 Well formations: Support extra headerlines within the csv file
This commit is contained in:
parent
3024b19b6f
commit
1675c17314
@ -24,8 +24,8 @@
|
||||
#include <QStringList>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -57,11 +57,28 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
|
||||
void removeWhiteSpaces(QString* word)
|
||||
{
|
||||
std::string wordStd = word->toStdString();
|
||||
wordStd.erase(std::remove_if(wordStd.begin(), wordStd.end(), [](unsigned char x) {return std::isspace(x); }), wordStd.end());
|
||||
wordStd.erase(std::remove_if(wordStd.begin(), wordStd.end(), [](unsigned char x) { return std::isspace(x); }), wordStd.end());
|
||||
|
||||
(*word) = QString(wordStd.c_str());
|
||||
}
|
||||
|
||||
bool isAHeaderLine(const QStringList& line)
|
||||
{
|
||||
if (line.empty()) return false;
|
||||
|
||||
QString word;
|
||||
|
||||
for (int i = 0; i < line.size(); i++)
|
||||
{
|
||||
word = line[i].toLower();
|
||||
removeWhiteSpaces(&word);
|
||||
|
||||
if (word.indexOf("wellname") != -1) { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -92,9 +109,9 @@ void RifWellPathFormationReader::readFileIntoMap(const QString&
|
||||
int surfaceNameIndex = header.indexOf(surfaceNameText);
|
||||
int measuredDepthIndex = header.indexOf(measuredDepthText);
|
||||
|
||||
if (wellNameIndex == -1 || surfaceNameIndex == -1 || measuredDepthIndex == -1)
|
||||
if (wellNameIndex == -1 || surfaceNameIndex == -1 || measuredDepthIndex == -1)
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
@ -102,8 +119,8 @@ void RifWellPathFormationReader::readFileIntoMap(const QString&
|
||||
QString line = data.readLine();
|
||||
|
||||
QStringList dataLine = line.split(';', QString::KeepEmptyParts);
|
||||
if (dataLine.size() != header.size())
|
||||
continue;
|
||||
if (dataLine.size() != header.size()) continue;
|
||||
if (isAHeaderLine(dataLine)) continue;
|
||||
|
||||
QString wellName = dataLine[wellNameIndex];
|
||||
QString surfaceName = dataLine[surfaceNameIndex];
|
||||
|
Loading…
Reference in New Issue
Block a user