-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] CsvEncoder no header option (encode / decode) #29283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here are some minor comments.
@redecs thank you for submitting PR. Do you plan to fix styling issue from review? I would like to see this feature in a core, please let me know, if I should fix it on your behalf. |
@diimpp Just pushed the CS fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a new feature, thus for master.
Thank you @redecs. |
…ode) (redecs) This PR was squashed before being merged into the 4.3-dev branch (closes #29283). Discussion ---------- [Serializer] CsvEncoder no header option (encode / decode) | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27447 | License | MIT | Doc PR | - This PR wants to introduce a new context option for the CsvEncoder, `CsvEncoder::NO_HEADERS_KEY` (boolean), that allows CSV encoding/decoding when you don't have/need a header. By default this is assumed to be false, so the headers are included in the CSV output or assumed to be present in the CSV input. When the option is set to true, the following behaviour occurs. Encoding === The following PHP input ```php array(array('a','b'), array('c', 'd')) ``` will generate this CSV output ```csv a,b c,d ``` Decoding === Considering the CSV input to be ```csv a,b c,d ``` the following PHP array will be returned ```php array ( 0 => array ( 0 => 'a', 1 => 'b', ), 1 => array ( 0 => 'c', 1 => 'd', ), ) ``` Commits ------- 0e63c61 [Serializer] CsvEncoder no header option (encode / decode)
This PR wants to introduce a new context option for the CsvEncoder,
CsvEncoder::NO_HEADERS_KEY
(boolean), that allows CSV encoding/decoding when you don't have/need a header.By default this is assumed to be false, so the headers are included in the CSV output or assumed to be present in the CSV input.
When the option is set to true, the following behaviour occurs.
Encoding
The following PHP input
will generate this CSV output
Decoding
Considering the CSV input to be
the following PHP array will be returned