Skip to main content

How to bulk delete spaces at the beginning/end of code via API?

Jaurel WANJI avatar
Written by Jaurel WANJI
Updated over a week ago

You can do that in two steps :

1 - Preparing your file.

  • Go to the advanced search page, select the object type and product type concerned, then click on “Add a filter”.

  • Filter on the “code” attribute, choose “Finish by” as the operation, press the space bar on your keyboard once in the value field, and finally click on “Filter”.

    Once the codes have been filtered in the search, select all results and:

  • Click on the “Actions” button, then on “Export results”.

  • Select “CSV” as the export type,CSV for Excel” as the encoding, remove all other attributes and leave only the ‘code’ attribute, then click “Export”.

    Once your file has been exported to your computer, open it and:

  • Rename your “codecolumn to “old_code”.

  • Duplicate this “old_codecolumn. If you don't know how to do this, you can consult this article.

  • Rename the duplicated columnnew_code” and delete all spaces at the end of the codes. If you need help doing this, you can go here.

  • Save your changes.

    After making the various changes, you should end up with a file with two columns, the first (old_code) containing the codes with spaces at the end and the second (new_code) containing the codes without spaces at the end.

2 - Import data via the API.

Install and run this script to modify your codes and remove any extra spaces:

Did this answer your question?