Skip to content

Commit e873d3e

Browse files
committed
Don't push empty rows
The current NEWLINE behavior of reading as much CR/LF as possible basically means empty rows are/should be ignored. This fixes the issue of pushing an empty row that can occur when the data chunk ends in the middle of such a CR/LF stream (either because of a block of empty lines or if you are unlucky because the chunk ended right in the middle of a Windows CRLF endline)
1 parent 23ac626 commit e873d3e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

single_include/csv.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7084,9 +7084,11 @@ namespace csv {
70847084
while (this->data_pos < in.size() && parse_flag(in[this->data_pos]) == ParseFlags::NEWLINE)
70857085
this->data_pos++;
70867086

7087-
// End of record -> Write record
7088-
this->push_field();
7089-
this->push_row();
7087+
// End of record -> Write non-empty record
7088+
if (!this->current_row.empty()) {
7089+
this->push_field();
7090+
this->push_row();
7091+
}
70907092

70917093
// Reset
70927094
this->current_row = CSVRow(data_ptr, this->data_pos, fields->size());

0 commit comments

Comments
 (0)