ListFerret mascot

Home › Guides › List to CSV: Turn a Column or List into a CSV File

List to CSV: How to Turn a Column or List into a CSV File

A CSV file is just text: values separated by commas, one record per line. That makes it the easiest format for moving a list into another system, such as a mailing tool, a CRM, a database import or a spreadsheet. It also makes it easy to get subtly wrong. This guide covers how to turn a list or a column into a CSV, in the simplest cases and in the awkward ones.

The quick answer

The sections below explain the rules that matter once your data contains commas, quotes, line breaks or numbers with leading zeros.

What a CSV actually is

CSV stands for comma-separated values. A tiny example with a header row looks like this:

name,city
Ava,Leeds
Ben,York

Each line is a record, and each comma separates two fields. There is no single official standard, but the widely followed description is RFC 4180, and it makes the key rules clear: fields that contain a comma, a double quote or a line break must be wrapped in double quotes, and a double quote inside a field is written as two double quotes.

Value in your listHow it must appear in the CSV
LeedsLeeds (no quotes needed)
Smith, John"Smith, John"
The "Big" Show"The ""Big"" Show"
A value with a line break insideWrapped in double quotes, with the line break kept inside them

Convert a list to CSV online

For a plain list, such as names, IDs or email addresses, the List to CSV Converter handles the quoting for you, and it can add a header row and download a ready-to-use .csv file:

  1. Paste the list, one item per line, into the List Converter.
  2. For a single row, set the output separator to Comma. For a single column, keep it as New line.
  3. If any item might contain a comma, set Wrap each item to double quotes and set Escape quotes inside items to the doubling option, which is the CSV convention (" becomes "").
  4. Copy the result. To get a header, type it on the first line yourself.
  5. Paste into a plain text editor and save the file with a .csv name.

The converter produces one row or one column. If you need several columns per record, such as name, city and email, build the table in a spreadsheet and export it, as described next.

From Excel or Google Sheets

Put each value in its own cell, with headings in row 1. Then:

Spreadsheets add the quotes for you where fields need them. One regional catch: in some countries Excel uses a semicolon as its list separator, so the “CSV” it saves is semicolon-separated. If the receiving system expects commas, check the file in a text editor before you upload it.

Common problems and how to avoid them

ProblemCauseFix
Leading zeros vanish (00123 becomes 123)Excel treats the column as numbers when it opens the fileImport with Data → From Text/CSV and set that column to Text, or open the CSV in a text editor instead
Long numbers show as 1.23E+15Excel converts big digit strings to scientific notationSame fix: import the column as Text
Accents show as strange symbolsThe file was saved in the wrong encodingSave as UTF-8
One value splits into two columnsIt contains a comma but is not wrapped in quotesWrap it in double quotes
A value starting with =, +, - or @ is treated as a formulaSpreadsheet programs may run it when the file is openedIf the file holds untrusted text, prefix such values with an apostrophe or a space before importing

The last row matters for security. If you build a CSV from text that other people supplied, a value such as =HYPERLINK(...) can be executed as a formula when someone opens the file in a spreadsheet. Treat untrusted lists with care before exporting them.

Convert a list to CSV in Python

If you do this regularly, Python’s built-in csv module applies the quoting rules for you, so you never have to think about them. This turns a list of strings into a one-column CSV with a header:

import csv

items = ["Ava", "Smith, John", 'The "Big" Show']

with open("out.csv", "w", newline="", encoding="utf-8") as f:
    writer = csv.writer(f)
    writer.writerow(["name"])
    writer.writerows([[item] for item in items])

The file contains a name header followed by Ava, "Smith, John" and "The ""Big"" Show", each on its own line. Three details matter:

A list of lists becomes several columns in one call:

rows = [["name", "city"], ["Ava", "Leeds"], ["Smith, John", "York"]]

with open("people.csv", "w", newline="", encoding="utf-8") as f:
    csv.writer(f).writerows(rows)

That writes name,city, then Ava,Leeds, then "Smith, John",York. If you use pandas, pandas.DataFrame({"name": items}).to_csv("out.csv", index=False) does the same job and also handles the quoting; index=False stops it adding a numbered first column.

The mistake to avoid is building the line yourself with ",".join(items). It works until a value contains a comma: the example above would produce Ava,Smith, John,The "Big" Show, which any CSV reader sees as four fields instead of three. To write the list as a single row the correct way, use csv.writer(f).writerow(items).

Going the other way

To turn a CSV row back into a list, see our guide to splitting a comma separated list into a column. Before you export, it is worth removing blanks and repeats with Remove Duplicates and putting the items in order with Sort Lines.

Frequently asked questions

How do I convert a list to a CSV file?

Put one value per line, add a header line if the importing system needs one, and save the text with a .csv extension in UTF-8. For a one-line list, join the items with commas using the List Converter.

How do I convert a column to CSV in Excel?

Use File, Save As and choose CSV UTF-8 (Comma delimited). Excel writes the column as one value per line and adds quotes where a value needs them.

What if my values contain commas?

Wrap each such value in double quotes. In the List Converter, set Wrap each item to double quotes and use the doubling option for Escape quotes inside items.

Why did my leading zeros disappear?

Excel converts numeric-looking text to numbers when it opens a CSV. Import the file with Data, From Text/CSV and set the column type to Text, or open it in a text editor.

Should I use commas or semicolons?

Use whatever the receiving system expects. Commas are the default, but in some regions spreadsheets export semicolon-separated files, so check the file before uploading it.

Try it now: use the free List to CSV Converter - private, instant and runs in your browser. Open List to CSV Converter →

More guides

Share this page: XFacebookLinkedInRedditEmail