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
];

Command icon 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

danielhonrade created an issue. See original summary.

andrewbelcher’s picture

Status: Active » Needs review
StatusFileSize
new936 bytes

Here'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.

andrewbelcher’s picture

Worth noting that this required CSV serialization 8.x-1.x-dev as there hasn't been a release including the upstream change.

andrewbelcher’s picture

StatusFileSize
new1.68 KB

Missed the schema update...

matthijs’s picture

StatusFileSize
new1.38 KB

Your patch doesn't seem to apply, the fixed patch is attached.

andrewbelcher’s picture

StatusFileSize
new1.63 KB

Re-rolled patch

cornifex’s picture

New patch for latest dev!

berdir’s picture

Status: Needs review » Needs work

Careful: 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.

andrey.baranovskiy’s picture

Status: Needs work » Needs review
StatusFileSize
new12.42 KB

Fixed issue from #8 and added tests.

jhedstrom’s picture

#9 looks good to me. It'd be great if folks above could confirm as well.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

This 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.

steven jones’s picture

This 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!

steven jones’s picture

Status: Reviewed & tested by the community » Needs review

Changing to a MR based on the patch in #9

steven jones’s picture

Status: Needs review » Reviewed & tested by the community

Setting to RTBC as before.

  • steven jones committed 8b18d5ca on 8.x-1.x
    Issue #3046184 by andrewbelcher, steven jones, cornifex, andrey....
steven jones’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone for your work on this issue, I've merged the MR and given liberal amounts of issue credit, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.