How to work with CSV Files in Magento 2 ( Part 1 )

What is CSV Files in Magento 2?

CSV Files is called as a short name of the comma-separated-value file format. It works like data transfer operation bases which is supported by all spreadsheet and database applications. Magento provides 2 file types of the comma-separated-value which are CSV and ZIP ( a compressed CSV file), therein, both CSV and ZIP are supported for import data, only CSV is supported for export data.

Feature of CSV Files in Magento 2

CSV Files have a particular construction that must absolutely match the database. Each column heading represents for a particular Attribute of the field. For example, name column show what the name of those products are, status column illustrates product’s current situation, etc. Moreover, we recommend you export the database from your store under a CSV Files’s construction to make sure that there is no column heading that Magento can read.

If you use a text editor to open an exported CSV file, you will see that values are isolated by commas, and multiple values are put inside double-quotes. During import, you can choose a custom separator character you want, thought a comma is the default.

To get more insight about CSV Files in Magento 2, please take attendance to the Product CSV Structure as well as Customer CSV Structure part right below.

Product CSV Files Structure in Magento 2

A full export of the product database gives you information about each product in the catalog, and the relationships between them. In that type of record, each column corresponds to the fixed attributes in the catalog.

Product CSV Files structure

The first row of the table which includes the names of each attribute is used as column headers. The remaining rows illustrate the particular product databases like store view code, product type, categories, description,…Any row that starts with a value in the SKU column is the beginning of a new product document. A individual product has to contain several rows that show data about multiple images or product options. The next row that has a value in the SKU column begins a new product.

The category column accommodates a path for each category which the product is selected. The path contains the root category, followed by a forward slash (/) between each level. By default, this “|” mark is used to isolate different category paths. For example: Default Category/Gear|Default Category/Gear/Watches which means that that product is putted in Watches Products Page in  Gear Category from Default Category.

If you want to import data, you only need to set the SKU and columns including changes. All of blank columns are neglected during the import process. You also can include only existing attributes as well.

To get more information about Customer CSV Files Structure, see Working with CSV Files part 2.