#1959 Observed Data : Use seekg after parsing header

This commit is contained in:
Magne Sjaastad 2017-10-03 09:49:08 +02:00
parent 2fc1d20f45
commit 4c61696f4e
3 changed files with 15 additions and 6 deletions

View File

@ -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
{

View File

@ -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++)
{

View File

@ -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);
};