Repository navigation
[Serializer] Skip empty lines when decoding multi-column CSV documents - #67752
Merged
Merged
Conversation
Empty lines are skipped when the first non-empty line of the document has several fields. In a single-column document, an empty line is a record with an empty value, so it is still decoded as one.
nicolas-grekas
force-pushed
the
fix/csv-encoder-blank-lines
branch
from
November 1, 2026 18:45
fe23431 to
48306bb
Compare
Member
|
Thanks for the PR. In a single-column CSV, an empty line is a record with an empty value. |
This was referenced Nov 4, 2026
Merged
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CsvEncoder::decode()turned the[null]thatfgetcsv()returns for an empty line into a row. In a multi-column document, this gave phantom rows like['a' => null], and an empty line before the header row garbled the whole result. Go'sencoding/csvand Python'scsv.DictReaderskip empty lines between records.This PR skips empty lines when the first non-empty line of the document has several fields. In a single-column document, an empty line is a record with an empty value. The encoder writes one for each
''ornullvalue, so these lines are still decoded as rows.Merge-up notes
Merge-up to 8.1: the
while (... fgetcsv(...))line indecode()conflicts. Resolve it toforeach ($this->readRows($handle, $delimiter, $enclosure) as $cols) {, then remove the$escapeCharargument ofreadRows()and pass''to its twofgetcsv()calls.