Please add the option for the CSV Header
$options['csv_settings']['contains'] = [
'delimiter' => ['default' => ','],
'enclosure' => ['default' => '"'],
'escape_char' => ['default' => '\\'],
'strip_tags' => ['default' => TRUE],
'trim' => ['default' => TRUE],
'encoding' => ['default' => 'utf8'],
'utf8_bom' => ['default' => FALSE],
'output_header' => ['default' => FALSE], // <-- This is already available in CSV Serialization module, https://www.drupal.org/project/csv_serialization/issues/2854087
];
| Comment | File | Size | Author |
|---|
Issue fork views_data_export-3046184
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
andrewbelcher commentedHere's a patch that does this. I've set the default to
TRUE, both as that is the more likely choice and for backwards compatibility.Comment #3
andrewbelcher commentedWorth noting that this required CSV serialization 8.x-1.x-dev as there hasn't been a release including the upstream change.
Comment #4
andrewbelcher commentedMissed the schema update...
Comment #5
matthijsYour patch doesn't seem to apply, the fixed patch is attached.
Comment #6
andrewbelcher commentedRe-rolled patch
Comment #7
cornifex commentedNew patch for latest dev!
Comment #8
berdirCareful: This breaks batch export badly, as there is a hardcoded assumption that the first row is a header line and is being removed. If you are using this with batch, you are missing data in your exports.
To verify that this works, this must extend or duplicate ViewsDataExportBatchTest and run the test again to make sure that the results are correctly exported without headers.
Comment #9
andrey.baranovskiy commentedFixed issue from #8 and added tests.
Comment #10
jhedstrom#9 looks good to me. It'd be great if folks above could confirm as well.
Comment #11
joelpittetThis looks great, has tests! And manually testing it also shows it works.
Thanks @andrewbelcher and others that helped, especially @Andrey.Baranovskiy for adding tests (EDIT and @Berdir for suggesting the data loss potential and need for tests). I don't need this feature (at the moment), but it is something I noticed lacking from the D7 version.
Comment #12
steven jones commentedThis was requested in #3157622: CSV - how to remove header row? and as #11 says this looks like a great patch and improvement, we should get this in!
Comment #13
steven jones commentedChanging to a MR based on the patch in #9
Comment #15
steven jones commentedSetting to RTBC as before.
Comment #17
steven jones commentedThanks everyone for your work on this issue, I've merged the MR and given liberal amounts of issue credit, thanks!