Showing with 7 additions and 8 deletions.
  1. +6 −5 src/datasources/ascii/asciidatareader.cpp
  2. +1 −3 src/datasources/ascii/asciisource.cpp
11 changes: 6 additions & 5 deletions src/datasources/ascii/asciidatareader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,17 @@ bool AsciiDataReader::findDataRows(const Buffer& buffer, qint64 bufstart, qint64
bool row_has_data = false;
bool is_comment = false;
const qint64 row_offset = bufstart + isLineBreak.size;
qint64 row_start = 0;
const qint64 old_numFrames = _numFrames;

// _rowIndex[_numFrames] already set, find next row

// _rowIndex[_numFrames] already set, find following rows
// buffer points to next row
qint64 row_start = _rowIndex[_numFrames];
for (qint64 i = 0; i < bufread; ++i) {
if (comment_del(buffer[i])) {
is_comment = true;
} else if (isLineBreak(buffer[i])) {
if (row_has_data) {
_rowIndex[_numFrames] = row_start;
++_numFrames;
if (_numFrames + 1 >= _rowIndex.size()) {
if (_rowIndex.capacity() < _numFrames + 1) {
Expand All @@ -202,10 +204,9 @@ bool AsciiDataReader::findDataRows(const Buffer& buffer, qint64 bufstart, qint64
_rowIndex.resize(_numFrames + 1);
}
row_start = row_offset + i;
_rowIndex[_numFrames] = row_start;
new_data = true;
} else if (is_comment) {
row_start = row_offset+i;
row_start = row_offset + i;
}
row_has_data = false;
is_comment = false;
Expand Down
4 changes: 1 addition & 3 deletions src/datasources/ascii/asciisource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,18 @@ bool AsciiSource::initRowIndex()
}
qint64 header_row = 0;
qint64 left = _config._dataLine;
qint64 didRead = 0;
while (left > 0) {
QByteArray line = file.readLine();
if (line.isEmpty() || file.atEnd()) {
return false;
}
didRead += line.size();
--left;
if (header_row != _config._fieldsLine && header_row != _config._unitsLine) {
_strings[QString("Header %1").arg(header_row, 2, 10, QChar('0'))] = QString::fromAscii(line).trimmed();
}
header_row++;
}
_reader.setRow0Begin(didRead);
_reader.setRow0Begin(file.pos());
}

return true;
Expand Down