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,20 +384,34 @@ bool RifCsvUserDataParser::parseColumnInfo( QTextStream*
|
||||
|
||||
QString unit;
|
||||
|
||||
// Check if unit is part of the column name in parentheses, e.g. "VECTOR (unit)".
|
||||
QRegExp exp( "\\((.*)\\)" );
|
||||
// Find unit from column header text
|
||||
// "VECTOR_NAME (unit)"
|
||||
// "VECTOR_NAME [unit]"
|
||||
{
|
||||
// "VECTORNAME (unit)" ==> "(unit)"
|
||||
QRegExp exp( "[[]([^]]+)[]]" );
|
||||
if ( exp.indexIn( colName ) >= 0 )
|
||||
{
|
||||
// "VECTOR (unit)" ==> "(unit)"
|
||||
QString fullCapture = exp.cap( 0 );
|
||||
// "VECTOR (unit)" ==> "unit"
|
||||
QString unitCapture = exp.cap( 1 );
|
||||
|
||||
unit = unitCapture;
|
||||
|
||||
// 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() )
|
||||
{
|
||||
|
@ -722,11 +722,6 @@ std::string RifEclipseSummaryAddress::itemUiText() const
|
||||
text += std::to_string( aquiferNumber() );
|
||||
}
|
||||
break;
|
||||
case SummaryCategory::SUMMARY_IMPORTED:
|
||||
{
|
||||
text += vectorName();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return text;
|
||||
|
Loading…
Reference in New Issue
Block a user