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:
Magne Sjaastad 2023-10-13 08:57:01 +02:00
parent 545eb57f7d
commit 7b28a23668
2 changed files with 24 additions and 15 deletions

View File

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

View File

@ -722,11 +722,6 @@ std::string RifEclipseSummaryAddress::itemUiText() const
text += std::to_string( aquiferNumber() );
}
break;
case SummaryCategory::SUMMARY_IMPORTED:
{
text += vectorName();
}
break;
}
return text;