On the import page for a specific CSV parser, you can download an example importer file using the 'Download a template'. This file has some shortcomings:
- the delimiter is always comma, even if you have set another delimiter in the corresponding field below, or in the 'default delimiter' field on the CSV-parser settigns page.
- Columns are duplicated: e.g. GUID is mapped to both GUID and a field. Now column GUID appears twice on the file.

Comments

johnv’s picture

Title: Import page: 'Download a template' is not correct » FeedsCSVParser Import page: Delimiter settings / Template file is not correct
Priority: Minor » Normal
Status: Active » Needs review
StatusFileSize
new1.42 KB

Also, the delimiter + no_header indicators are not representative for the Parser.

Attached patch fixes all three problems.

johnv’s picture

A revised patch against latest -dev.

both page and template file now have thefollowing options
- no duplicate columns, even if they are defined in the mapper;
- same order, having unique columns upfront;
- correct delimiter;
- re-use fo configForm, resulting in lesser code.

twistor’s picture

Issue summary: View changes
Status: Needs review » Needs work

Arg. I've never used the template generation. This needs work, since the duplicate fields has been fixed already. The default configuration should be solved by having the sourceDefaults() use configDefaults().

megachriz’s picture

This issue could be closed in favor of #1988970: FeedsCSV parser - download template should use the default delimiter which has a more recent patch. Not sure though, since this issue seems to want to do more than just adjusting the delimiter in the csv template.

johnv’s picture

@MegaChriz, it is good practice to close the newer issue. And, - like you noticed - the other issue only repairs the template file partly.

msti’s picture

The 2nd issue about duplicate fields in the csv template has already been commited: #1996240: Duplicate fields in CSV template

megachriz’s picture

Toraih’s picture

Example for adding # as delimiter:

/**
 * Implements hook_form_alter()
 *
 * Add new delimiter for IDX (#) to FeedsCSVParser_feeds_form
 *
 */
function mymodulename_form_alter(&$form, $form_state, $form_id) {
    if('FeedsCSVParser_feeds_form' == $form_id){
        $form['delimiter']['#options']['#'] = '#';
    }
}

*edit* oops, wrong page...