What is a CSV-file

If your code works fine don’t touch it!

CSV (from English. Comma-Separated Values - values, separated by commas) - text format, designed to represent tabular data. Row of the table corresponds to a line of text, which contains one or more fields, separated by commas (wikipedia.org).

CSV format is not fully standardized. Name format – CSV (meaning, separated by commas) – It indicates that the field separator is a comma. Nevertheless, the term “CSV” It can be used to refer to similar formats. Many programs understand CSV under a common format DSV (delimiter-separated values - values ​​separated by a delimiter), allowing the use of different symbols as a separator.

In other words, a text file, which contains information in the form of individual lines, where each line is a separate record (for example one product). separator ( delimiter) values ​​of columns (CSV field delimiter) It is a comma (,) or semicolon (;).

text delimiter – meaning, containing reserved characters (double quote, comma, semicolon, new line) are enclosed in double quotes (“). If the value of quotes there - they appear in the file as two consecutive quotes.

Name CSV fields – The first line of the file name usually keep CSV fields (speakers) to identify these fields (speakers).


An example of CSV-file

The original text of the CSV file, where each row is a table row:

_ID_;_NAME_;_MODEL_;_PRICE_
28;"HTC Touch HD";"Product 1";1750.0000
29;"Palm Treo Pro";"Product 2";112.0000
30;"Canon EOS 5D";"Product 3";113.0000

Table view when opened in Apache OpenOffice Calc:

_ID_ _NAME_ _MODEL_ _PRICE_
28 “HTC Touch HD” “Product 1” 1750.0000
29 “Palm Treo Pro” “Product 2” 112.0000
30 “Canon EOS 5D” “Product 3” 113.0000

To see the contents of the CSV-file you can open in any text editor, such as Notepad ++ (How to check the format of a CSV file) or in any other test editor.


How to create a CSV file

The most convenient and fastest way to get the CSV file template of the correct format – do export of goods by expanding CSV Price Pro import / export. For this section Products (eng. Products) tab Export (eng. Export)., select the necessary fields for export on the right and export, as a result, you will get a CSV file ready for work


How to open and edit CSV-file

The first thing to do, is to download and install the Office suite Apache OpenOffice, in which structure there Apache OpenOffice Calc, spreadsheet application, allows you to work with files in CSV format.

When opening a CSV file in an application Apache OpenOffice Calc select parameters according to the settings as shown in the screenshot below:
  • Character set: Unicode (UTF-8)
  • Separator options: Semicolon (;)
  • Text delimiter: Double quote (“)
  • Quote field as text – Checked
  • Right click menu to select column type as Text (always Text eng. Text)
Open CSV-file

How to save a CSV file

Microsoft Excel will open .csv files, but depending on the system’s regional settings, it may expect a semicolon as a separator instead of a comma, since in some languages the comma is used as the decimal separator. Also, many regional versions of Excel will not be able to deal with Unicode characters (UTF-8) in a CSV file.
OpenCart works in encoding Unicode (UTF-8), to avoid problems associated with processing CSV files in various encodings, use encoded files Unicode (UTF-8).

In order to save the file in CSV format, select File > Save As.

In the window that appears, select the file type Text CSV (.csv), install “checkmark” on the contrary that appears at the bottom of the item Edit filter settings Change filter settings

press Save .

In the window that opens, select the option Use the current format

In the window that opens Export to a text file select:

  • Character set: Unicode (UTF-8)
  • Field delimiter: Semicolon (;)
  • Text delimiter: Double quote (“)
  • Quote all text cells – Checked

press OK to save.


How to check the format of a CSV file

CSV is a simple and common format for tabular data, this is a simple text file, which contains text without formatting and has the CSV extension (.csv) instead of the traditional TXT extension (.txt), such a file can be opened by any word processing program.

Here is a non-exhaustive list of applications for opening plain text .txt or .csv files:

  • Microsoft Notepad (Windows)
  • Microsoft WordPad (Windows)
  • Helios TextPad (Windows)
  • Notepad++ (Windows)
  • Notepad2 (Windows)
  • Geany (Windows, Mac, Linux)
  • Apple TextEdit (Mac)
  • Apple Pages (iOS)
  • Leafpad (Linux)
  • gedit (Linux)
  • KWrite (Linux)