<Solved> How to edit field separators used for back office CSV imports



  • I use openoffice calc and save new spreadsheets with the .ods file extension until I’m ready to convert it to a .csv file.

    Every time I go to import in admin I have to keep changing the field separator and multivalue separator depending on whether I’m importing categories, products or combinations.

    Screenshot shows field delimiter and text delimiter when exporting from .ods to .csv

    0_1497540995930_what field delimiters do I save when converting ods to csv.jpg

    @spidawebs can you help me out please?


  • Global Moderator

    You mean you want to change the default setting in the import page?



  • Yes, please, but also need to know what to enter on the csv so they match.


  • Global Moderator

    The defaults are semicolon for the fields, and comma for multiple values. They should actually stay the same across entities

    admin: themes\default\template\controllers\import\helpers\form\form.tpl

    Holds the defaults when there is none set yet in the cookie


  • Global Moderator

    Here

    <input id=“separator” name=“separator” class=“fixed-width-xs form-control” type=“text” value="{if isset($separator_selected)}{$separator_selected|escape:‘html’:‘UTF-8’}{else};{/if}" />



  • This post is deleted!

  • Global Moderator

    This post is deleted!


  • This post is deleted!


  • @Nemo Thanks so much for making it easy to follow! It works perfectly.



  • @Nemo I have been using new field separators for a long while now with great success. Can you please tell me how to edit the code so that these are the default separators?

    Field separator: ^ (caret above #6 on keyboard)

    Multiple value separator: comma

    Thank you,
    Stephanie


  • Global Moderator

    Stephanie,
    Could you clarify? You mean setting them as default in the configuration?

    admin folder \themes\default\template\controllers\import\helpers\form\form.tpl

    They are hardcoded in there, just search the labels, they are if statements



  • @Nemo Yes, I want to set the defaults but I don’t understand how to edit / update what the below is from the last time we did this:

    <input id=“separator” name=“separator” class=“fixed-width-xs form-control” type=“text” value="{if isset($separator_selected)}{$separator_selected|escape:‘html’:‘UTF-8’}{else};{/if}" />

    The image in the first post is where I want to change the settings again. I can see the quote mark but somehow can’t see where to put the other setting. I’ll try again tomorrow with a fresh view.

    Thanks,

    Stephanie



  • This part:

    value="{if isset($separator_selected)}{$separator_selected|escape:‘html’:‘UTF-8’}{else};{/if}"

    Reads like this:

    “If the user selected a separator, use that selected separator, otherwise use semicolon (;).”

    So, you only have to change this part that sets the semicolon as the default separator:

    {else};{/if}



  • @Nemo I saw the code much easier in Sublime than in my text editor, so that was great.

    @moy2010 Thank you for translating it so I would understand it. :)

    Between the two of you, I believe I now know what I am doing. Unfortunately, it is still not working.


    In the form.tpl file, I changed the field separator as follows: {else}^{/if} (caret)

    The multiple value separator was how I wanted it: {else},{/if} (comma)


    I updated the Field and Multiple Value Separators in the form.tpl but the admin csv separators will not update.

    They stay at: field separator is a comma and the multiple value separator is a semicolon.

    My updated field separator code and updated multiple value separator code is as follows:

    <div class=“form-group”>
    <label for=“separator” class=“control-label col-lg-4”>{l s=‘Field separator’}</label>
    <div class=“col-lg-8”>
    <input id=“separator” name=“separator” class=“fixed-width-xs form-control” type=“text” value="{if isset($separator_selected)}{$separator_selected|escape:‘html’:‘UTF-8’}{else}^{/if}" />
    <div class=“help-block”>{l s='e.g. '} 1, Blouse, 129.90, 5</div>
    </div>
    <div class=“form-group”>
    <label for=“multiple_value_separator” class=“control-label col-lg-4”>{l s=‘Multiple value separator’}</label>
    <div class=“col-lg-8”>
    <input id=“multiple_value_separator” name=“multiple_value_separator” class=“fixed-width-xs form-control” type=“text” value="{if isset($multiple_value_separator_selected)}{$multiple_value_separator_selected|escape:‘html’:‘UTF-8’}{else},{/if}" />
    <div class=“help-block”>{l s='e.g. '} red.jpg; blue.jpg; green.jpg</div>
    </div>
    </div>
    </div>
    </div>


    This screenshot is from my file manager on my host because I wanted to confirm the file was actually updated. (I used Filezilla to download the file, edited it with Sublime and uploaded it with Filezilla.)

    0_1512567757634_SG-file-manager-form-template-updated-2017-12-06 at 8.13.23 AM.jpg

    This screenshot shows the settings have not changed in the admin - CSV import section:

    0_1512567904835_admin-shows-old-csv-import-settings-2017-12-06 at 8.14.58 AM.jpg


    This screenshot is the updated form.tpl file:

    0_1512568002526_form-template-updated-code-2017-12-06.jpg

    I use CSV uploads very regularly.

    Anyone with suggestions as to why the form.tpl does not change the csv upload default parameters?

    Thanks,

    Stephanie



  • Can someone please see what may be wrong with the code? Even the multiple value separator doesn’t work and I didn’t have to change it.

    Is there anywhere else the defaults can be changed for these csv import separators in admin?



  • @alwayspaws

    Why do you want to change the code in the script? My best experiences with the CSV files are field separators as a semicolon and the separator for multi-valued fields as a comma.

    Before the import, I only have to turn each time in the two input fields so that it works. But it works great with me.

    0_1513378835045_3c0a880f-4d82-4f25-9446-8303a75a0a76-grafik.png



  • @zimmer-media Remember this? https://forum.thirtybees.com/topic/931/solved-how-to-use-csv-import-for-many-colors-sizes-for-a-single-product/115 - I’m not going through that again.

    My csv’s work perfectly. I just want to change the separators in the admin csv import section. Someone here has to know why the updated form.tpl doesn’t work.

    @Traumflug Any ideas, please?

    Thanks.



  • Everything seems to be alright in the code; have you cleared both smarty and your browser’ cache?



  • Yes. And tried with three browsers.



  • I’m still trying to change the default field separator and multiple value separator in the back office for CSV imports. I want the field separator to be a caret which is this symbol: ^
    and the multiple value separator to be a comma.

    It’s been two weeks since I updated ONE CHARACTER in the code and uploaded the edited form.tpl so, supposedly, any cache that was stuck should be cleared by now if it is cache I cannot clear myself in admin or my three browsers.

    The only change to the existing code was to change the comma to a caret for the field separator.

    The multiple value separator was already a comma, so it did not need changing, however, it still has the multiple value separator as a semicolon in the CSV import section in the back office.

    That, in itself, means something else needs to be updated.

    What can it be, please?

    Here is the field separator code:

    <input id=“separator” name=“separator” class=“fixed-width-xs form-control” type=“text” value="{if isset($separator_selected)}{$separator_selected|escape:‘html’:‘UTF-8’}{else}^{/if}" />

    and here is the multiple value separator code:

    <input id=“multiple_value_separator” name=“multiple_value_separator” class=“fixed-width-xs form-control” type=“text” value="{if isset($multiple_value_separator_selected)}{$multiple_value_separator_selected|escape:‘html’:‘UTF-8’}{else},{/if}" />

    and here is the screenshot of the updated form.tpl:

    0_1514656778131_multiple value and field separators form template code edited uploaded Screen Shot 2017-12-30 at 12.19.05 PM.jpg

    Here it shows the latest updated file exists on my host:

    0_1514656832579_form-template-updated-shows-in-file-manager-on-host.jpg

    @SLiCK_303 Maybe you can help me figure this out. You’re great at finding solutions.


Log in to reply
 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.