mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4017 Automatic parsing of date-time format in CSV Observed Time History Data
This commit is contained in:
@@ -218,6 +218,52 @@ QString RifCsvUserDataParser::previewText(int lineCount, const AsciiDataParseOpt
|
||||
return preview;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RifCsvUserDataParser::timeColumnPreviewData(int lineCount, const AsciiDataParseOptions& parseOptions)
|
||||
{
|
||||
QStringList timeStrings;
|
||||
|
||||
QTextStream* stream = openDataStream();
|
||||
|
||||
if (stream)
|
||||
{
|
||||
int timeColumnIndex = -1;
|
||||
int iLine = 0;
|
||||
|
||||
while (iLine < lineCount && !stream->atEnd())
|
||||
{
|
||||
QString line = stream->readLine();
|
||||
|
||||
if (line.isEmpty()) continue;
|
||||
|
||||
int iCol = 0;
|
||||
QStringList cols = RifFileParseTools::splitLineAndTrim(line, parseOptions.cellSeparator);
|
||||
for (const QString& cellData : cols)
|
||||
{
|
||||
if (cellData == parseOptions.timeSeriesColumnName && iLine == 0)
|
||||
{
|
||||
timeColumnIndex = iCol;
|
||||
}
|
||||
|
||||
if (iLine > 0 && timeColumnIndex != -1 && timeColumnIndex == iCol)
|
||||
{
|
||||
timeStrings.push_back(cellData);
|
||||
}
|
||||
|
||||
iCol++;
|
||||
}
|
||||
|
||||
iLine++;
|
||||
}
|
||||
}
|
||||
|
||||
closeDataStream();
|
||||
|
||||
return timeStrings;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -784,4 +830,4 @@ void RifCsvUserDataPastedTextParser::closeDataStream()
|
||||
delete m_textStream;
|
||||
m_textStream = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user