Active
Project:
CSV Serialization
Version:
4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 Dec 2021 at 12:00 UTC
Updated:
13 Aug 2025 at 10:11 UTC
Jump to comment: Most recent
I'm using views_data_export module to export a view result as csv file. Everything works well untill the view we want to export is empty. If there is no result, the csv header row is not generated and the file is empty.
The extractHeaders method seems to priorities results keys over view fields in case of view context. It doesn't seems to be a bug.
The file is empty with no header row.
In case we have a views_style_plugin context, assume that view fields are our header (at least when there is no data).
I'm not sure why this filtering code has been written so I don't know if we can just remove it.
Choose either if we keep that filtering feature or not.
Comments
Comment #2
colin.eininger commentedComment #3
markdorisonComment #4
s3b0un3tHello,
I also needed to generate a CSV with headers even when there were no results.
I'm providing my code as an example for others who may have this issue.
In a
*.modulefile, i declare a hook:Don't forget to rename the
mymodulehook function name prefix with your module name and themy_view_idwith your view ID.Regards,