-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
CSV-encoding header documentation seems to be a bit misleading #15243
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
Comments
Original comment no longer makes sense because the PR description was updated with examples. Thanks! |
sorry accidentally pressed enter |
@javiereguiluz I added a few more lines to the issue, sorry for prematurely submitting :) |
Sorry for using the word "irritating" - it wasn't meant offensive in any way, but I can see how one could interpret it that way :) |
Theo, thanks a lot for reporting this issue ... and for your quick reaction changing that term. Hopefully this will be reviewed soon and we can improve the reported problem. Cheers! |
Thank you for this issue. |
Hello? This issue is about to be closed if nobody replies. |
no, I think the point still stands (at least I don't know if anything has happened in that regard since my initial submission) |
Closing in favor of #17912, a meta-issue that groups all pending serializer-related issues so we can easily check them. |
This PR was merged into the 5.4 branch. Discussion ---------- Adapt CsvEncoder `no_headers` context Try fix #15243 Default behavior: https://github.com/symfony/symfony/blob/c7a7cb8841bb54a68c967b3ea0e57024802b96ed/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php#L45-L60 With `no_headers` https://github.com/symfony/symfony/blob/c7a7cb8841bb54a68c967b3ea0e57024802b96ed/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php#L647-L653 Commits ------- 2bfe5da Adapt CsvEncode no_headers context
Hey,
I just started using the
CSVEncoder
and hat some trouble getting it to work with flat data.The
no_headers
flag and its description are very misleading in my opinion.I wanted to create some simple csv like this:
However from the docs it was really hard to figure out how to specify my custom headers, because of the way the conding handles nested data:
This would not work, because the encoder would automatically set the headers to the surrounding arrays indices [0,1,2].
If I had written this instead:
I would get nested headers instead.
So the solution for this would be to set the
no_headers => true
flag for the context.This makes sense if you think about how CSV works, but especially the description "Disables header in the encoded CSV" makes my brain think along the lines "oh, no headers at all" (which of course is nonsense).
I would probably add something along the lines "Disable automatic headers. Use the first data row instead" and maybe add an example, instead.
I can create a PR with an example and suggested documentation if that helps :)
The text was updated successfully, but these errors were encountered: