mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 16:32:12 -05:00
#2003 Observed Data : Add basic support for fixed width in parser
This commit is contained in:
1 parent
50b2717ed2
commit
f50760bb35
4 files changed
+43
-42
No files matched your search
@@ -66,14 +66,28 @@ const ColumnInfo* RifColumnBasedUserDataParser::columnInfo(size_t tableIndex, si
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RifColumnBasedUserDataParser::parseTableData(const QString& data)
|
void RifColumnBasedUserDataParser::parseTableData(const QString& data)
|
||||||
{
|
{
|
||||||
|
std::string stdData = data.toStdString();
|
||||||
|
bool isFixedWidth = RifEclipseUserDataParserTools::isFixedWidthHeader(stdData);
|
||||||
|
|
||||||
std::stringstream streamData;
|
std::stringstream streamData;
|
||||||
streamData.str(data.toStdString());
|
streamData.str(stdData);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
std::vector<std::string> errorStrings;
|
std::vector<std::string> errorStrings;
|
||||||
|
|
||||||
auto table = RifEclipseUserDataParserTools::tableDataFromText(streamData, &errorStrings);
|
TableData table;
|
||||||
|
|
||||||
|
if (isFixedWidth)
|
||||||
|
{
|
||||||
|
auto columnInfos = RifEclipseUserDataParserTools::columnInfoForFixedColumnWidth(streamData);
|
||||||
|
table = TableData("", "", "", columnInfos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
table = RifEclipseUserDataParserTools::tableDataFromText(streamData, &errorStrings);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_errorText)
|
if (m_errorText)
|
||||||
{
|
{
|
||||||
for (auto s : errorStrings)
|
for (auto s : errorStrings)
|
||||||
|
|||||||
@@ -503,11 +503,7 @@ TableData RifEclipseUserDataParserTools::tableDataFromText(std::stringstream& st
|
|||||||
|
|
||||||
RifEclipseSummaryAddress adr = RifEclipseUserDataKeywordTools::makeAndFillAddress(quantity, columnHeader);
|
RifEclipseSummaryAddress adr = RifEclipseUserDataKeywordTools::makeAndFillAddress(quantity, columnHeader);
|
||||||
|
|
||||||
ColumnInfo ci(adr, unit);
|
ColumnInfo ci = ColumnInfo::createColumnInfo(quantity, unit, adr);
|
||||||
if (quantity == "DATE")
|
|
||||||
{
|
|
||||||
ci.isStringData = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
columnInfos.push_back(ci);
|
columnInfos.push_back(ci);
|
||||||
}
|
}
|
||||||
@@ -728,28 +724,11 @@ std::vector<ColumnInfo> RifEclipseUserDataParserTools::columnInfoFromColumnHeade
|
|||||||
|
|
||||||
RifEclipseSummaryAddress adr = RifEclipseUserDataKeywordTools::makeAndFillAddress(quantity, restOfHeader);
|
RifEclipseSummaryAddress adr = RifEclipseUserDataKeywordTools::makeAndFillAddress(quantity, restOfHeader);
|
||||||
|
|
||||||
ColumnInfo columnInfo;
|
ColumnInfo ci = ColumnInfo::createColumnInfo(quantity, unit, adr);
|
||||||
columnInfo.unitName = unit;
|
|
||||||
|
|
||||||
// if (hasDateUnit(unit) ||
|
table.push_back(ci);
|
||||||
// hasDateUnit(quantity))
|
|
||||||
// {
|
|
||||||
// columnInfo.isAVector = false;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// columnInfo.isAVector = true;
|
|
||||||
// }
|
|
||||||
//columnInfo.origin = origin;
|
|
||||||
//columnInfo.dateFormatString = dateFormat;
|
|
||||||
//columnInfo.startDateString = startDate;
|
|
||||||
|
|
||||||
columnInfo.summaryAddress = adr;
|
|
||||||
|
|
||||||
table.push_back(columnInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,3 +838,17 @@ bool RifEclipseUserDataParserTools::isUnitText(const std::string& word)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
ColumnInfo ColumnInfo::createColumnInfo(const std::string& quantity, const std::string& unit, const RifEclipseSummaryAddress& adr)
|
||||||
|
{
|
||||||
|
ColumnInfo ci(adr, unit);
|
||||||
|
|
||||||
|
if (RifEclipseUserDataParserTools::hasDateUnit(quantity))
|
||||||
|
{
|
||||||
|
ci.isStringData = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ci;
|
||||||
|
}
|
||||||
@@ -49,6 +49,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static ColumnInfo createColumnInfo(const std::string& quantity, const std::string& unit, const RifEclipseSummaryAddress& adr);
|
||||||
|
|
||||||
RifEclipseSummaryAddress summaryAddress;
|
RifEclipseSummaryAddress summaryAddress;
|
||||||
std::string unitName;
|
std::string unitName;
|
||||||
double scaleFactor;
|
double scaleFactor;
|
||||||
|
|||||||
@@ -149,15 +149,12 @@ TEST(FixedWidthDataParser, DetectFixedWidth)
|
|||||||
|
|
||||||
EXPECT_TRUE(RifEclipseUserDataParserTools::isFixedWidthHeader(data.toStdString()));
|
EXPECT_TRUE(RifEclipseUserDataParserTools::isFixedWidthHeader(data.toStdString()));
|
||||||
|
|
||||||
// RifColumnBasedUserDataParser parser(data);
|
RifColumnBasedUserDataParser parser(data);
|
||||||
// auto tables = parser.tableData();
|
auto tables = parser.tableData();
|
||||||
// EXPECT_EQ(3, tables.size());
|
EXPECT_EQ(size_t(3), tables.size());
|
||||||
|
|
||||||
/*
|
EXPECT_EQ(size_t(10), tables[0].columnInfos().size());
|
||||||
auto mergedTables = RifEclipseUserDataParserTools::mergeEqualTimeSteps(tables);
|
EXPECT_EQ(size_t(13), tables[0].columnInfos()[0].stringValues.size());
|
||||||
EXPECT_EQ(1, mergedTables.size());
|
|
||||||
EXPECT_EQ(28, mergedTables[0].size());
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -210,13 +207,8 @@ TEST(FixedWidthDataParser, VaryingTimeStepCount)
|
|||||||
" 14-NOV-1997 0 2637960. 5415305. 592557.9 0 10541.03 0 14.09936 -38974.5 \n"
|
" 14-NOV-1997 0 2637960. 5415305. 592557.9 0 10541.03 0 14.09936 -38974.5 \n"
|
||||||
;
|
;
|
||||||
|
|
||||||
// RifColumnBasedUserDataParser parser(data);
|
RifColumnBasedUserDataParser parser(data);
|
||||||
// auto tables = parser.tableData();
|
auto tables = parser.tableData();
|
||||||
// EXPECT_EQ(2, tables.size());
|
EXPECT_EQ(2, tables.size());
|
||||||
|
|
||||||
/*
|
|
||||||
auto mergedTables = RifEclipseUserDataParserTools::mergeEqualTimeSteps(tables);
|
|
||||||
EXPECT_EQ(2, mergedTables.size());
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user