How to Make a CSV File: Methods, Tools, and What to Know First

CSV files are one of the most universally useful data formats in computing — and creating one is simpler than most people expect. Whether you're exporting contact lists, preparing data for import into an app, or sharing structured information between systems, understanding how CSV files work helps you create them correctly the first time.

What Is a CSV File, Exactly?

CSV stands for Comma-Separated Values. It's a plain-text file format that stores tabular data — rows and columns — using commas to separate each value and line breaks to separate each row. There's no special encoding, no formatting, no formulas. Just text.

A basic CSV looks like this in its raw form:

Name,Email,City Alice,[email protected],Austin Bob,[email protected],Denver 

That's a complete, functional CSV file. The first row typically contains headers (column names), and every row below it contains matching data values. Because it's plain text, nearly every spreadsheet application, database, programming language, and data platform can read and write CSV files without any conversion.

Method 1: Create a CSV in a Spreadsheet App

The most common approach — and the easiest for most users — is building the data in a spreadsheet application and saving it as CSV.

Works with:

  • Microsoft Excel
  • Google Sheets
  • LibreOffice Calc
  • Apple Numbers

In Excel or LibreOffice Calc:

  1. Open a new spreadsheet
  2. Enter your headers in Row 1 (e.g., Name, Phone, Date)
  3. Enter your data in the rows below
  4. Go to File → Save As
  5. Choose CSV (Comma delimited) or CSV UTF-8 from the file format dropdown
  6. Save — the app will warn you that formatting won't be preserved, which is expected

In Google Sheets:

  1. Build your data as you normally would
  2. Go to File → Download → Comma-Separated Values (.csv)
  3. The file downloads immediately to your device

One important note: when saving as CSV from a spreadsheet, only the active sheet is exported. If your workbook has multiple tabs, each tab needs to be exported separately.

Method 2: Write a CSV File Manually in a Text Editor 📄

Because CSV is plain text, you can create one from scratch in any text editor — Notepad on Windows, TextEdit on Mac, Gedit on Linux, or any code editor like VS Code.

Steps:

  1. Open your text editor
  2. Type your headers on the first line, separated by commas
  3. Press Enter and type each data row, matching the same column order
  4. Save the file with a .csv extension (e.g., contacts.csv)

This method gives you full control and is useful when you need a small, precise file or when you're troubleshooting a CSV that another app is rejecting.

Watch for these common issues:

  • Values that contain commas — wrap them in double quotes: "Smith, John"
  • Line endings — Windows uses CRLF, Unix/Mac use LF; most apps handle both, but some systems are picky
  • Encoding — save as UTF-8 to safely include accented characters, symbols, or non-Latin text

Method 3: Export a CSV From Another Application

Many tools generate CSV files directly — no manual creation needed. This is how most people end up with CSVs in practice.

SourceHow to Export
CRM (e.g., HubSpot, Salesforce)Contacts → Export → Choose CSV
E-commerce platformsOrders/Products → Export → CSV
Email marketing toolsLists → Export subscribers
Database tools (MySQL, PostgreSQL)Query results → Export as CSV
Survey tools (Typeform, Google Forms)Responses → Download CSV

The resulting file is ready to use, but it's worth opening it in a text editor or spreadsheet app to verify the structure — especially if you plan to import it somewhere else.

Method 4: Generate a CSV Programmatically

If you're working with data at scale or automating a workflow, generating CSVs through code is the standard approach.

Python has a built-in csv module:

import csv with open('output.csv', 'w', newline='') as f: writer = csv.writer(f) writer.writerow(['Name', 'Email', 'City']) writer.writerow(['Alice', '[email protected]', 'Austin']) 

JavaScript (Node.js) can write CSV using the fs module or libraries like fast-csv or papaparse.

Excel formulas and macros can also generate CSV-compatible output, though most developers prefer scripting for repeatable tasks.

Key Variables That Affect How Your CSV Behaves 🔧

Creating a CSV file is straightforward — making one that works correctly in its destination is where things vary.

Delimiter choice: While commas are standard, some regions use semicolons as the default delimiter (common in countries where commas serve as decimal separators). A file that opens perfectly in one locale may misparse in another.

Encoding: UTF-8 is the safe default for modern systems. If your CSV is destined for older Windows software or certain legacy enterprise tools, UTF-8 with BOM or even Windows-1252 encoding may be required.

Quoting rules: How your source application handles fields containing commas, quotes, or newlines varies. Inconsistent quoting is a leading cause of import failures.

Header row expectations: Some platforms require headers; others treat the first row as data. Knowing what the receiving system expects matters before you build the file.

Column order and naming: When importing CSVs into a database, CRM, or app, the column names and their sequence often need to match a specific schema exactly — or the import will fail silently or map incorrectly.

What Determines Which Method Is Right for You

The method that makes most sense depends on factors specific to your situation: how much data you're working with, whether this is a one-time task or a recurring process, what application will consume the file, and your comfort level with tools like text editors or scripting languages.

A marketer exporting a contact list once a month has a completely different workflow than a developer generating daily transaction reports. A CSV built for Google Sheets behaves differently than one destined for a PostgreSQL import or a legacy payroll system. The format is simple — but what surrounds it is where the real differences emerge.