The import and export function for CSV files in Shopware is helpful when you need to change or create a large amount of data. However, there are a few things to keep in mind when using it – especially when opening, editing, and saving CSV files. Below, we'll show you step by step for Microsoft Excel and LibreOffice Calc what you need to consider so that the CSV file is displayed correctly in your spreadsheet program and can also be imported back into Shopware correctly.
What is a CSV file and how does it "work"?
A CSV file is a simple text file that stores data in tabular form. Each line in the file corresponds to a row of data, and the values within a row are separated from each other by semicolons or other characters. Here you can see an example of the content of a CSV file showing the absolute stock of a product at different storage bins. The first line indicates the respective column names.
Produktname;Produktnummer;Lager;Lagerkürzel;Lagerplatz;Standardlagerplatz;Bestand"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;unbekannt;nein;-24"Aerodynamic Concrete CoffeeMatic";SW10071;Nachfülllager;NL;C-03-006;ja;150"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;B-02-002;nein;90"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;C-02-007;ja;50"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;C-03-004;nein;125
How is a CSV file read and processed?
1. The file is read line by line – so the order of the entries matters. This means that if an entry occurs multiple times with different values, the later value will overwrite the previous one. Here's an example:
The last line of the example CSV file above reads as follows:
"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;C-03-004;nein;125
When reading this line, the stock of 125 is written for product SW10071 at storage bin C-03-004 in the main warehouse. Suppose another line follows in the CSV file that refers to the same combination of product number, warehouse, and storage bin, but contains a different stock value. For example:
"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;C-03-004;nein;100
In that case, when reading this line, 100 units would not be added to the already written 125 units. Instead, the stock for product SW10071 at storage bin C-03-004 in the main warehouse would be overwritten. The final stock would therefore be 100 units, not 225!
2. Only what is in the file is processed. No independent logical assumptions are made. For example, if you want to move stock from storage bin A to storage bin B, your CSV file must contain two lines for this.
Here, as an example, in the context of an absolute stock import, 90 units of a product are booked to storage bin A-01-001 in the first line (absolute stock = 90). In the second line, 90 units of the product are removed from storage bin B-02-002 (absolute stock = 0)
Produktname;Produktnummer;Lager;Lagerkürzel;Lagerplatz;Standardlagerplatz;Bestand"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;A-01-001;nein;90"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;B-02-002;nein;0
In a relative stock import, the same change would look like this
Produktname;Produktnummer;Lager;Lagerkürzel;Lagerplatz;Standardlagerplatz;Änderung"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;A-01-001;nein;90"Aerodynamic Concrete CoffeeMatic";SW10071;Hauptlager;HL;B-02-002;nein;-90
If only the first line is contained in the CSV file, only stock would be booked in at the new storage bin, but no stock would be booked out at the old storage bin. As a result, your actual stock would be 90 units too high.
3. The location of the import determines which data can be changed. For example, in the stock overview, a CSV import can only change the stock at the respective storage bins. If you change the product name in the import file, this has no effect on the actual product. If you specify a storage bin that does not exist, it will not be created automatically. Instead, the relevant record will not be imported, and an error message will appear in the import report. There is a separate import interface for creating storage bins, where, accordingly, no stock can be changed either.
General procedure
Regardless of the program you use, the following points must be considered when editing the CSV file for the Shopware Import/Export tool:
Export the relevant profile as a CSV file from Shopware and use it as a template.
Open the file as a CSV file in a spreadsheet program.
Important: the encoding must be UTF-8 and the separator must be a semicolon.
Finally, the file must be exported or saved again as a semicolon-separated CSV file in UTF-8 format.
CSV import/export with Excel (from Excel 2010)
First, perform a CSV export with the desired profile in your Shopware shop.
Open a new document in Excel.
Import the CSV file by navigating to the Data tab and clicking Get Data → From Text.
Select Delimited and choose Unicode (UTF-8) as the file origin, then click Next at the bottom.
Select the semicolon as the delimiter.
When editing the file, make sure to use the same decimal separator that you configured in the Import/Export tool. In Excel, you can set the separator for decimal numbers via the advanced options.
The exported file can now be used as a template and filtered and edited accordingly.
Save the edited file as a CSV file in UTF-8 format
Finally, import the CSV file into your shop.
CSV import/export with LibreOffice Calc
Open LibreOffice.
Select the CSV file via Open File.
Similar to Excel, a dialog will open where you need to make the settings as described above.
Confirm the settings by clicking OK.
The exported file can be used as a template and filtered and edited accordingly. Make sure to use the same decimal separator as in Shopware.
Save the file as a CSV file in UTF-8 format. To do this, select Save As and check the box for Edit filter settings. Then click Use CSV Format and, in the dialog that appears, select UTF-8 format again.
What to do if my spreadsheet program does not support UTF-8 encoding?
If your spreadsheet program does not support valid UTF-8 encoding, you can ensure UTF-8 encoding as follows: open the edited CSV file in a text editor and save it there as a UTF-8-encoded CSV file. By taking this detour through the editor, the file can be saved correctly in UTF-8 format.
For the import into Shopware, the CSV file must be UTF-8 encoded. To be safe, test the import beforehand in a test environment or in the staging system. Before performing the import on the live system, it's advisable to create a database backup first.
