How to Create CSV Files (WooCommerce CSV Import Example)
This article answers the question that man has wrestled with since the days when fire was considered cutting edge tech- how to create CSV files to handle all the data. One way is to open a plain text editor and start typing. Another way is to use a CSV editor like Modern CSV. Finally, you can export a CSV file. By way of example, I’ll use WooCommerce, a popular e-commerce platform for WordPress. I’ll cover how to export a CSV from WooCommerce, build a product list in Modern CSV, and import the modified CSV back into WooCommerce.
What is a CSV File?
A CSV (comma separated value) file is a plain text file representing a table of information. Commas typically separate the columns and newline characters (e.g. the Enter key) separate the rows.
If a cell has commas or newlines, surround the cell with double quote characters. If it has double quote characters, type them in twice and also surround the cell with double quotes.
Typically, the first row is a header row labeling the columns. The rows that follow are records.
CSV files sometimes use tabs, pipes (|), or semicolons to separate the columns. They may be called TSVs, PSVs, or DSVs respectively.
How to Manually Create CSV Files
Suppose you want to make a CSV file of actors you’ve seen in movies and TV recently for some reason. If you made it in a text editor, it might look like this:
That’s not especially convenient. The columns don’t align, you can’t sort by birthdate or filter to only see women or people born in a certain country. If you want to insert a column or move columns around, you’re in for a lot of manual labor. Additionally, you have to surround the birthplace entries with double quotes. If you mess it up, your file will be misaligned. Plus, it just looks awkward.
If you’d rather not deal with that, try Modern CSV instead. Here’s what the same file looks like:
Now, you can use a ton of great features that operate on both rows and columns.
Let’s use a more realistic example of how you might use a CSV editor in real life.
Export a CSV from WooCommerce and Import the CSV Back
WooCommerce is an e-commerce tool that makes it easy to export product data and import it back in CSV format.
Suppose you’re setting up an e-commerce store to sell your custom-made art products. You have a million products that will take a thousand years to type manually in your browser. Here’s a much easier approach:
- Manually enter a single product in WooCommerce.
- Export it to CSV.
- Enter the rest of the products with Modern CSV.
- Import it back to WooCommerce.
1. Manually enter a single product in WooCommerce.
Enter all the product descriptions, variations (like color), SEO data, images, etc. for just one product. This will serve as the template for the rest:
2. Export it to CSV.
In the WordPress sidebar, go to Products.
Hit the Export button.
Check the “Export custom meta?” option and hit the Generate CSV button. Then, download the file.
You have just created a simple CSV file that already has the header information need to add the rest of your products.
3. Enter the rest of the products with Modern CSV.
Open the file with Modern CSV.
It may be awkward scrolling horizontally to see all the fields. If you wish, you can transpose it using the Transpose Table command (ctrl+alt+t for Windows and Linux, cmd+alt+t for Mac). More about transposing here.
Or you can leave it as it was.
Perhaps you have a bunch of similar products that only differ on the specifics. You can duplicate the first product’s row several times with the Duplicate Rows command (ctrl+alt+r for Windows and Linux, cmd+alt+r for Mac).
You can create new IDs in the ID column with the Fill Selected Cells with Series command (ctrl+alt+n for Windows and Linux, cmd+alt+n for Mac).
You can then select row 2 and call the Replace command (ctrl+h in Windows and Linux, cmd+alt+f in Mac). Then, you can replace the product name using the Match Only in Selected Cells option. This option will automatically be selected when multiple cells are selected.
For editing the description, you’ll probably want to use newline characters and such. With the editor pane, you can do that. It’ll be like typing in a plain text editor. You can enable it with the Toggle Show Editor Pane command (crtl+k,ctrl+e for Windows and Linux, cmd+shift+e for Mac).
You can escape out of it with the esc key or navigate out with alt+i (up), alt+l (right), alt+j (left), or alt+k (down).
4. Import it back to WooCommerce.
Once you add all your products to the CSV and edit them, you can save import them back to WooCommerce. In WordPress, go back to the Product screen and click the Import button.
On the next screen, point it to the file and hit Continue.
When the process is done, you might have some errors. Fortunately, the error log is actually helpful. In this case, I left the SKUs the same for each of the products.
Back in Modern CSV, I update the SKUs…
and try again. This time, it worked and I can see all my products:
This is one example of how you can create CSV files with Modern CSV using WooCommerce’s CSV export and CSV import features. You can perform similar actions with all sorts of e-commerce platforms and databases. Instead of slogging through tedious user interfaces, you can use Modern CSV to quickly edit your data.