mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-20 11:48:35 -06:00
#1959 Observed Data : Use seekg after parsing header
This commit is contained in:
parent
2fc1d20f45
commit
4c61696f4e
@ -52,17 +52,17 @@ void RifColumnBasedUserDataParser::parseData(const QString& data)
|
||||
{
|
||||
std::stringstream streamData;
|
||||
streamData.str(data.toStdString());
|
||||
std::string line;
|
||||
std::getline(streamData, line);
|
||||
|
||||
do
|
||||
{
|
||||
std::vector<ColumnInfo> table = RifEclipseUserDataParserTools::columnInfoForTable(streamData, line);
|
||||
std::vector<ColumnInfo> table = RifEclipseUserDataParserTools::columnInfoForTable(streamData);
|
||||
size_t columnCount = table.size();
|
||||
if (columnCount == 0) break;
|
||||
|
||||
std::string line;
|
||||
std::getline(streamData, line);
|
||||
|
||||
std::vector<double> values;
|
||||
|
||||
QString qLine;
|
||||
do
|
||||
{
|
||||
|
@ -259,7 +259,7 @@ bool RifEclipseUserDataParserTools::keywordParser(std::string line, std::string&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<ColumnInfo> RifEclipseUserDataParserTools::columnInfoForTable(std::stringstream& streamData, std::string& line)
|
||||
std::vector<ColumnInfo> RifEclipseUserDataParserTools::columnInfoForTable(std::stringstream& streamData)
|
||||
{
|
||||
std::vector<ColumnInfo> table;
|
||||
|
||||
@ -267,10 +267,13 @@ std::vector<ColumnInfo> RifEclipseUserDataParserTools::columnInfoForTable(std::s
|
||||
std::string dateFormat = "";
|
||||
std::string startDate = "";
|
||||
|
||||
std::string line;
|
||||
std::getline(streamData, line);
|
||||
|
||||
while (isLineSkippable(line) || keywordParser(line, origin, dateFormat, startDate))
|
||||
{
|
||||
if (!streamData.good()) return table;
|
||||
|
||||
std::getline(streamData, line);
|
||||
}
|
||||
|
||||
@ -312,9 +315,13 @@ std::vector<ColumnInfo> RifEclipseUserDataParserTools::columnInfoForTable(std::s
|
||||
|
||||
std::vector< std::vector< std::string > > restOfHeader;
|
||||
|
||||
std::stringstream::pos_type posAtStartOfLine = streamData.tellg();
|
||||
|
||||
bool header = true;
|
||||
while (header)
|
||||
{
|
||||
posAtStartOfLine = streamData.tellg();
|
||||
|
||||
std::getline(streamData, line);
|
||||
|
||||
std::vector<std::string> words = splitLineAndRemoveComments(line);
|
||||
@ -344,6 +351,8 @@ std::vector<ColumnInfo> RifEclipseUserDataParserTools::columnInfoForTable(std::s
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
streamData.seekg(posAtStartOfLine);
|
||||
|
||||
for (size_t i = 0; i < columnCount; i++)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
static size_t findFirstNonEmptyEntryIndex(std::vector<std::string>& list);
|
||||
static RifEclipseSummaryAddress makeAndFillAddress(std::string quantityName, std::vector< std::string > headerColumn);
|
||||
static bool keywordParser(std::string line, std::string& origin, std::string& dateFormat, std::string& startDate);
|
||||
static std::vector<ColumnInfo> columnInfoForTable(std::stringstream& data, std::string& line);
|
||||
static std::vector<ColumnInfo> columnInfoForTable(std::stringstream& data);
|
||||
static bool isANumber(const std::string& line);
|
||||
static std::vector<std::string> headerReader(std::stringstream& streamData, std::string& line);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user