Skip to Content

How to create CSV file in Excel?

A CSV (comma separated values) file allows data to be saved in a table structured format, where each column is separated by a comma. CSV files can be opened by most spreadsheet programs, but are simple text files which store tabular data. CSV files are commonly used for exporting data from one program to be imported into another. For example, you may export contacts from an email program into a CSV file, which can then be opened in Excel.

Excel provides a simple way to create CSV files. In this article, we will cover everything you need to know to easily create CSV files using Excel, including:

  • What is a CSV file?
  • When to use a CSV file
  • The CSV file format
  • How to create a CSV file in Excel
  • Setting CSV file options in Excel
  • Opening CSV files in Excel
  • Pros and cons of CSV files

What is a CSV File?

CSV stands for “comma separated values”. A CSV file is a simple text file where values are separated by commas, hence the name. CSV files store data in a tabular format, where each row represents a record and each column represents a field of the record. For example:

Column 1 Column 2 Column 3
Value 1 Value 2 Value 3
Value 4 Value 5 Value 6

As you can see, the values for each column are separated by commas. This simple structure allows CSV data to be exported and imported between programs that store data in tables, like Excel or databases.

When to Use a CSV File

Here are some common situations when you may want to use a CSV file:

  • Exporting data – Save tables of data from Excel or other programs to share the data using a simple format.
  • Transferring data – Move tabular data between different applications.
  • Storing spreadsheet data – Use as a basic data format for storing spreadsheet data and exchanging with others.
  • Loading data – Import CSV data into Excel or databases for analysis and reporting.
  • Simplifying data – Remove complex formatting and formulas and save just the values for portability.

The simple structure of CSV files allows them to be used for basic data import and export by many programs. The plaintext format stores just the data values, removing other complex elements like formulas and formatting. This flexibility makes CSV an ideal format for sharing spreadsheet data.

The CSV File Format

CSV files are simple text files that can be created and edited using any plaintext editor. The format consists of rules for how the data values should be organized in a CSV file:

  • Data is organized in rows and columns
  • Rows represent records or data entries
  • Columns represent fields or attributes
  • Columns are separated by commas
  • Rows are separated by newlines
  • All cells are plain text with no formatting
  • The first row often contains column headers
  • Strings can be quoted to escape commas and newlines

Following these rules allows CSV data to be rendered correctly when imported into spreadsheet and database programs. Values that contain reserved characters like commas or newlines can be wrapped in double quotes to be parsed properly.

Many settings like the delimiter character and quoting rules can be configured when importing CSV data into a program. But the standard format uses commas and quotes to organize tabular data into a plain text file.

How to Create a CSV File in Excel

It’s easy to create a CSV file from an Excel worksheet. Here are the steps:

  1. Open the Excel sheet you want to save as a CSV
  2. Click File > Save As in the top menu
  3. Choose “CSV (Comma delimited)” from the “Save as type” dropdown
  4. Give the file a name and select a save location
  5. Click “Save”

That’s all there is to it! By default, Excel will automatically format your data correctly for a CSV file. The Save As dialog also provides options to configure CSV settings like delimiter type and encoding.

You can also export Excel data to CSV by selecting only the data you want, and clicking Copy/Paste Special > Values. Then paste the cells into a blank CSV file or text editor.

Setting CSV File Options in Excel

When saving an Excel file to CSV, the Save As dialog provides options to set the CSV format and encoding.

Delimiters

Delimiters determine how the CSV data will be separated into columns. By default Excel uses a comma as the delimiter. But you can choose other characters like tabs, semicolons, or pipes.

Quoting Rules

You can determine when Excel will wrap values in quotes. By default, strings will only be quoted when required, like when they contain the delimiter character. You can also force all values or headers to be quoted.

Encoding

Encoding determines the character set used to save the CSV text. UTF-8 is common for CSV files, but you can also choose options like ANSI or Unicode.

Setting the correct encoding ensures special characters and languages are exported properly.

Line Breaks

Line breaks determine how rows are separated in the CSV. You can choose between Windows (CRLF) and Mac (CR) line endings.

Choosing the right line break format ensures the CSV rows are parsed correctly by other programs.

Taking the time to select the right encoding and delimiters for your data helps ensure the CSV file will be imported correctly.

Opening CSV Files in Excel

Once you have a CSV file, opening it in Excel is straightforward.

  1. In Excel, click File > Open
  2. Browse to the CSV file and select it
  3. The Text Import Wizard will open. Ensure “Delimited” is selected and click Next
  4. Select Comma for the delimiter and any other desired settings
  5. Click Finish

The CSV data will now load into an Excel spreadsheet. The Text Import Wizard gives you options to configure how the CSV is loaded and formatted.

You can choose options like data type and delimiter on the second step of the wizard. On the final step you can select formatting options for the imported data.

Once loaded, you can work with the CSV data just like any other spreadsheet. Use Excel’s powerful tools to analyze, chart, and report on the data.

Pros and Cons of CSV Files

CSV is a simple but flexible format for spreadsheet data. Here are some key pros and cons:

Pros

  • Simple structure is easy to export, import, read, create, and parse
  • Plain text is compatible with almost every spreadsheet program and database
  • Small file size compared to XLSX or other binary formats
  • Human-readable in a text editor
  • No proprietary formatting or features to get in the way

Cons

  • Limited support for data types
  • No built-in support for formulas or macros
  • Formatting like colors, fonts, and cell alignment are not saved
  • Less compact than binary spreadsheet formats like XLSX
  • More difficult to handle large datasets compared to databases

Understanding the strengths and limitations helps determine when to use CSV vs XLSX or database formats.

Conclusion

CSV files provide a convenient method for exporting, formatting, and importing spreadsheet data. By following the standard CSV format, you can easily share tabular data between many types of programs.

Excel makes it simple to convert worksheet data into a CSV file for portability and exchange. Save your spreadsheets to CSV to remove extraneous formatting and share with other applications.

With Excel’s powerful tools, you can easily load CSV data, analyze it, and create charts and reports. The CSV format removes complexity and helps you focus on working with your spreadsheet data.