How to create a CSV file? Step by step guide

Descubra en este artículo todo lo que necesita saber sobre el archivo csv y cómo crear un archivo csv de forma sencilla.

THE files in CSV format can be imported and exported from programs that store data in tables, such as Microsoft Excel, Google Spreadsheet, or OpenOffice Calc.

CSV stands for comma-separated values. This abbreviation simply comes from the fact that the data fields of a CSV file are most often separated or delimited by a comma.

What is a CSV file?

A CSV file is a simple file format used to store table data, such as a spreadsheet or database.

Example CSV file

For example, let’s say you have a spreadsheet containing the following data.

NameFirst nameAge
DupontJules24 years
MartinMelissa19 years old
LebollecStephane31 years

The above data could be represented in a CSV format file like: Nom,Prénom,Age Dupont,Jules,24 ans Martin,Mélissa,19 ans Lebollec,Stéphane,31 ans

Here, the data fields in each row are comma delimited and we wrap for each new row in the table.

You may also like: How to find any font?

Creating a CSV File: rules to follow

Although there is no standard structure for CSV files, there are similar “rules” used by many software programs and systems. Please make sure your CSV file follows these rules:

  • Each row has the same number of values ​​(fields), and sometimes the values ​​are surrounded by quotation marks (“””).
  • Empty fields must be separated by commas and/or quotation marks.
  • Make sure there are no blank lines in the CSV file.
  • Remove unnecessary spaces at the beginning or end of each field.✅ “Lucas”
    ? » Lucas »
    ? » Lucas «

A CSV is a text file, so it can be created and edited using any text editor. More commonly, however, a CSV file is created by exporting (File menu ? Export as CSV) a spreadsheet or database into the program that created it.

Here are some software programs that allow you to create a CSV file :

  • Notepad (or any other text editor)
  • Microsoft Excel
  • OpenOffice Calc
  • Google Docs

You may also like: The 10 best free image banks

Create a CSV file with Google Sheets

To create a CSV file with Google Spreadsheets for example, fill in your table as you wish and then file? Download as…? CSV. And now, voila.

export to csv - LeDigitalizeur
export to csv - LeDigitalizeur

Create a CSV file with commas

In the CSV file you just created, the individual data fields were separated by commas. But what if the data itself contains commas?

If the data fields in your CSV file contain commas, you can protect them by enclosing these data fields in quotation marks (“ ).

The commas which are part of your data will then be separated from the commas which delimit the fields themselves.

For example, let’s say one of our text fields is our users’ location created by them directly and users are allowed to put commas in the field.
Our data will look like this:

NameFirst nameLocation
DupontJulesParis, France
MartinMelissaLondon, UK
LebollecStephaneNew York, USA

To keep commas in our “Location” column, we can enclose these fields in quotes.

For example : Nom,Prénom,Localisation Dupont,Jules,”Paris, France” Martin,Mélissa,”London, UK” Lebollec,Stéphane,”New York, USA”

As you can see, only fields that contain commas are surrounded by quotes.

Create a CSV file with commas and quotes

If your fields contain double quotes in their data, the inner quotes must be doubled so that they can be interpreted correctly. For example, given the following data:

NameFirst nameLocation
DupontJules” Paris, France “
MartinMelissa“London, UK”
LebollecStephane“New York, USA”

We can represent it in a CSV file like this: Nom,Prénom,Localisation Dupont,Jules,””Paris, France”” Martin,Mélissa,””London, UK”” Lebollec,Stéphane,””New York, USA””

Here we simply doubled the quotes for the location column.

Finally, don’t forget to encode your CSV file in UTF-8 to handle special characters.

To save a CSV file under Google Sheets for example, follow the following steps:

  1. Click on file
  2. Click Download
  3. Then finally click on Comma Separated Values ​​(.csv)
  4. Then choose the file name and click save.