mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improve parsing of units in CSV column headers
Detect units enclosed by both () and [] Avoid duplicate vector name in UI
This commit is contained in:
parent
545eb57f7d
commit
7b28a23668
@ -384,19 +384,33 @@ bool RifCsvUserDataParser::parseColumnInfo( QTextStream*
|
|||||||
|
|
||||||
QString unit;
|
QString unit;
|
||||||
|
|
||||||
// Check if unit is part of the column name in parentheses, e.g. "VECTOR (unit)".
|
// Find unit from column header text
|
||||||
QRegExp exp( "\\((.*)\\)" );
|
// "VECTOR_NAME (unit)"
|
||||||
if ( exp.indexIn( colName ) >= 0 )
|
// "VECTOR_NAME [unit]"
|
||||||
{
|
{
|
||||||
// "VECTOR (unit)" ==> "(unit)"
|
// "VECTORNAME (unit)" ==> "(unit)"
|
||||||
QString fullCapture = exp.cap( 0 );
|
QRegExp exp( "[[]([^]]+)[]]" );
|
||||||
// "VECTOR (unit)" ==> "unit"
|
if ( exp.indexIn( colName ) >= 0 )
|
||||||
QString unitCapture = exp.cap( 1 );
|
{
|
||||||
|
QString fullCapture = exp.cap( 0 );
|
||||||
|
QString unitCapture = exp.cap( 1 );
|
||||||
|
|
||||||
unit = unitCapture;
|
unit = unitCapture;
|
||||||
|
colName = RiaTextStringTools::trimAndRemoveDoubleSpaces( colName.remove( fullCapture ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove unit from name
|
{
|
||||||
colName = RiaTextStringTools::trimAndRemoveDoubleSpaces( colName.remove( fullCapture ) );
|
// "VECTOR_NAME [unit]" ==> "[unit]"
|
||||||
|
QRegExp exp( "[(]([^)]+)[)]" );
|
||||||
|
if ( exp.indexIn( colName ) >= 0 )
|
||||||
|
{
|
||||||
|
QString fullCapture = exp.cap( 0 );
|
||||||
|
QString unitCapture = exp.cap( 1 );
|
||||||
|
|
||||||
|
unit = unitCapture;
|
||||||
|
colName = RiaTextStringTools::trimAndRemoveDoubleSpaces( colName.remove( fullCapture ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( auto it = nameMapping.find( colName ); it != nameMapping.end() )
|
if ( auto it = nameMapping.find( colName ); it != nameMapping.end() )
|
||||||
|
@ -722,11 +722,6 @@ std::string RifEclipseSummaryAddress::itemUiText() const
|
|||||||
text += std::to_string( aquiferNumber() );
|
text += std::to_string( aquiferNumber() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SummaryCategory::SUMMARY_IMPORTED:
|
|
||||||
{
|
|
||||||
text += vectorName();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
Loading…
Reference in New Issue
Block a user