I have a CSV export attachment that's destined to get migrated back in with Migrate (after an external process adds more data).
So I'd like the CSV header to have strings that are in machine-friendly format, that is, lowercase, numbers, and underscores only.
On the other hand, with the page display that the CSV is attached to, it would be nice to keep this with human-readable labels.
And finally, I really don't want to have to override all the fields on the CSV attachment display just to change the field labels -- that will be an extra maintenance burden if fields are added in future.
Hence I think a simple feature to add would be an option for the CSV export to convert the labels to machine name format. Patch coming!
Comment | File | Size | Author |
---|---|---|---|
#9 | json-export-machine-names.png | 276.59 KB | szeidler |
#6 | interdiff-2298025-3-6.txt | 2.61 KB | Shreya Shetty |
#6 | views_data_export-2298025-6.patch | 3.05 KB | Shreya Shetty |
#4 | views_data_export-2298025-4.patch | 1.98 KB | Shreya Shetty |
#3 | views_data_export-machine_names_as_labels-2298025.patch | 1.98 KB | efpapado |
Comments
Comment #1
joachim CreditAttribution: joachim commentedComment #2
efpapado CreditAttribution: efpapado at Ramsalt Lab commentedHello,
If I get it well, your patch does not use the actual machine name of the fields, but rather gets the field label and converts the string in a way that is compatible with machine names.
But wouldn't it be better to use the machine name itself?
Comment #3
efpapado CreditAttribution: efpapado at Ramsalt Lab commentedI propose this patch
Comment #4
Shreya Shetty CreditAttribution: Shreya Shetty as a volunteer and at Trigyn Technologies Ltd commentedThis is a very good feature to be included in Views data Export. Sio that it gives the flexibility for the user to replace the header with the machine name of the field. Please include this patch in the next release. I have tested the patch it works fine.
Comment #5
efpapado CreditAttribution: efpapado at Ramsalt Lab commentedCan you attach also an interdiff?
Comment #6
Shreya Shetty CreditAttribution: Shreya Shetty as a volunteer and at Trigyn Technologies Ltd commentedAm extremely sorry @efpapado that I created a patch which was same as your patch. My bad when I applied the patch it wasn't getting applied so thought of creating a patch on the latest version.
But now I have made some improvements which provide the flexibility for the user to select the field which will be having the machine name of the field if the field is not selected it will be having the label as it was working previously. Thank You for the previous patch.
Hope this feature gets committed soon so that the user get more options for the header labels. Providing interdiff for the same.
Comment #7
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedI can confirm the patch #3 is working like charm and I use that approach for every big XML and JSON export, where I don't want to handle the labels manually.
Moving forward to RTBC.
Comment #8
wheretoplaygames CreditAttribution: wheretoplaygames commentedI've applied these patches, but do not see the any results. Do i have to scrap my current view and create a new one?
Testing the one with the checkbox to force field names. Where should i be seeing this checkbox?
Comment #9
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedYou don't need to recreate the view.
You might need to clear your the cache before.
Comment #10
wheretoplaygames CreditAttribution: wheretoplaygames commentedThank you, szeidler! Your image helped me because i was looking in the wrong place for the checkbox.