@@ -23,6 +23,10 const auto DATE_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz"); | |||
|
23 | 23 | /// Separator between values in a result line |
|
24 | 24 | const auto RESULT_LINE_SEPARATOR = QRegularExpression{QStringLiteral("\\s+")}; |
|
25 | 25 | |
|
26 | /// Regex to find the header of the data in the file. This header indicates the end of comments in | |
|
27 | /// the file | |
|
28 | const auto DATA_HEADER_REGEX = QRegularExpression{QStringLiteral("#\\s*DATA\\s*:")}; | |
|
29 | ||
|
26 | 30 | /// Regex to find unit in a line. Examples of valid lines: |
|
27 | 31 | /// ... PARAMETER_UNITS : nT ... |
|
28 | 32 | /// ... PARAMETER_UNITS:nT ... |
@@ -75,8 +79,8 Unit readXAxisUnit(QTextStream &stream) | |||
|
75 | 79 | { |
|
76 | 80 | QString line{}; |
|
77 | 81 | |
|
78 | // Searches unit in the comment lines | |
|
79 |
while (stream.readLineInto(&line) && |
|
|
82 | // Searches unit in the comment lines (as long as the reading has not reached the data header) | |
|
83 | while (stream.readLineInto(&line) && !line.contains(DATA_HEADER_REGEX)) { | |
|
80 | 84 | auto match = UNIT_REGEX.match(line); |
|
81 | 85 | if (match.hasMatch()) { |
|
82 | 86 | return Unit{match.captured(1), true}; |
@@ -186,7 +190,6 std::shared_ptr<IDataSeries> AmdaResultParser::readTxt(const QString &filePath, | |||
|
186 | 190 | auto xAxisUnit = readXAxisUnit(stream); |
|
187 | 191 | |
|
188 | 192 | // Reads results |
|
189 | stream.seek(0); // returns to the beginning of the file | |
|
190 | 193 | auto results = readResults(stream, valueType); |
|
191 | 194 | |
|
192 | 195 | // Creates data series |
General Comments 0
You need to be logged in to leave comments.
Login now