mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2225 Well formations: Support extra headerlines within the csv file
This commit is contained in:
@@ -24,8 +24,8 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@@ -57,11 +57,28 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
|
|||||||
void removeWhiteSpaces(QString* word)
|
void removeWhiteSpaces(QString* word)
|
||||||
{
|
{
|
||||||
std::string wordStd = word->toStdString();
|
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());
|
(*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 surfaceNameIndex = header.indexOf(surfaceNameText);
|
||||||
int measuredDepthIndex = header.indexOf(measuredDepthText);
|
int measuredDepthIndex = header.indexOf(measuredDepthText);
|
||||||
|
|
||||||
if (wellNameIndex == -1 || surfaceNameIndex == -1 || measuredDepthIndex == -1)
|
if (wellNameIndex == -1 || surfaceNameIndex == -1 || measuredDepthIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -102,8 +119,8 @@ void RifWellPathFormationReader::readFileIntoMap(const QString&
|
|||||||
QString line = data.readLine();
|
QString line = data.readLine();
|
||||||
|
|
||||||
QStringList dataLine = line.split(';', QString::KeepEmptyParts);
|
QStringList dataLine = line.split(';', QString::KeepEmptyParts);
|
||||||
if (dataLine.size() != header.size())
|
if (dataLine.size() != header.size()) continue;
|
||||||
continue;
|
if (isAHeaderLine(dataLine)) continue;
|
||||||
|
|
||||||
QString wellName = dataLine[wellNameIndex];
|
QString wellName = dataLine[wellNameIndex];
|
||||||
QString surfaceName = dataLine[surfaceNameIndex];
|
QString surfaceName = dataLine[surfaceNameIndex];
|
||||||
|
|||||||
Reference in New Issue
Block a user