Hi,
Thank you for the module. I am able to export the output as a csv with just one issue. The headings for the columns in the csv export have the machine names of the fields instead of the labels. So for example first name is one of the fields in the export and its label is First Name and the machine is field_first_name, the csv export has field_first_name as the heading in the first row. Could you please let me know if there is something I am missing or if there is a way I can achieve that.
Thank you.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | headings_in_csv_have-2772937-8.patch | 1.91 KB | plov |
| #7 | headings_in_csv_have-2772937-7.patch | 1.89 KB | pauloamgomes |
| #6 | headings_in_csv_have-2772937-6.patch | 1.74 KB | borisson_ |
Comments
Comment #2
d34dman commentedRight now to fix your issue you would have to put custom labels in your views ui under Format >> Fields >> settings. Unfortunately it doesn't support spaces. This is probably because in other form of serialization is meant to be used for m2m (machine to machine) communication. CSV is exceptional case, and has to be handled differently, which as far as i know, is not supported yet
Comment #3
hongpong commentedIs there a way to hard code in replacement headers for individual columns? It would be nice to force in spaces for a client use case. (their vendor wants spaces in the headers, don't ask me why.)
Comment #4
d34dman commented@HongPong i can understand your predicament. Been through that. A CSV export can have spaces in header. It is supposed to be human readable names. (not saying machine names are not human readable, but still).
How i achieved it is by creating my own Normalizer plugin that extended NormalizerBase, which returned result keyed by "labels contain spaces". Well it is an overkill but fortunately i am a developer who is comfortable with coding.
Comment #5
hongpong commentedI'm still getting the hang of plugins and haven't really studied how these pieces fit together in D8 serialization / views world - if some snippet is available in a repo or github gist that would be a thrill.
Comment #6
borisson_This make the header row actually use the views settings.
Comment #7
pauloamgomes commentedMinor update on @borisson_ patch, applies ok against 8.x-1.x-dev
Comment #8
plov commentedRe-roll against #2859030-2: Support UTF-8 signature in export.
Comment #11
grasmash commentedComment #12
hongpong commentedthank you grasmash :)
Comment #14
c-logemannThis new feature is breaking the API and causes fatal errors when this module is used e.g. with "Contact Storage Export". There is already an issue for that: #2916034: Fatal error when using CSV Encoder without views context
I just did a quick view into code but I think also the provided tests won't work. Maybe the test system for patches should be enabled to avoid a bug like this in future.