Articles
Published · November 18, 2026

Mail Merge a Holiday Card List From a CSV File and Markdown Table

Keep your holiday card address list as a CSV, proof it as a Markdown table, and merge it into envelope text with a short script. Covers quoting, blanks, and reuse next year.

Also in: Español中文हिन्दी

A holiday card address list works best as three plain-text pieces: a CSV file as the master, a Markdown table for proofreading, and a short template that merges each row into envelope text. None of it needs a mail merge app.

Set up the CSV for a holiday card address list

Start with one row per household and one column per part of the address. Splitting the address into parts lets you rebuild it in any order later.

name,line1,line2,city,region,postal,sent_2026
Ana Torres,12 Main St,"Apt 4, Rear",Portland,OR,97201,
Sam Okafor,7 Elm Ct,,Austin,TX,78701,yes
"Jo ""JJ"" Park",90 Oak Ave,,Denver,CO,80202,

A header line is optional in CSV, but you want one here because the merge step refers to columns by name. Two other rules from RFC 4180, the document that describes the common CSV format, apply to every row:

  • Spaces are part of a field and should not be ignored, and the last field in a record must not be followed by a comma.
  • Fields containing line breaks, double quotes, or commas should be enclosed in double quotes.

That second rule is why "Apt 4, Rear" is quoted above. A literal double quote inside a quoted field is written as two double quotes, which is how the nickname in the third row survives. The RFC is informational, not an Internet standard, and it says some programs deviate from it. If you export from a spreadsheet, open the raw file as text once and check that the quoting looks like the example.

Don't split on commas yourself

You might be tempted to write a quick split(","). Don't. The Wikipedia article on CSV warns that a CSV cannot be parsed by naively splitting the data on line terminators and then splitting each line on commas, because quoted fields can contain both. Use a real CSV reader instead. Python's built-in csv module is one, and spreadsheet importers do the same job.

Two more checks before you merge:

  • Encoding. CSV is commonly used with UTF-8, but the file has no way to say which encoding it uses. If an accented name turns into odd characters, the file and the reader disagree about the encoding.
  • Separators. Excel has its own CSV dialect, and the separator is not always a comma, so semicolon-separated exports exist. If every row looks like one long column, check the separator first.

Turn the CSV into a Markdown table

A raw CSV is hard to proofread. The same rows as a table are easy to scan for a missing postal code or a duplicate household. If you need the general steps, we cover how to convert a spreadsheet or CSV into a Markdown table separately. For this list the result looks like this:

| name | line1 | line2 | city | region | postal | sent_2026 |
| --- | --- | --- | --- | --- | --- | --- |
| Ana Torres | 12 Main St | Apt 4, Rear | Portland | OR | 97201 | |
| Sam Okafor | 7 Elm Ct | | Austin | TX | 78701 | yes |
| Jo "JJ" Park | 90 Oak Ave | | Denver | CO | 80202 | |

The quoting is gone. In the table, commas are ordinary text and the doubled quotes collapse back to single ones.

Rules that break the table

The GitHub Flavored Markdown spec defines tables, and four of its rules matter for an address list. For syntax and alignment details, see Markdown table syntax and alignment.

  • The header row must match the delimiter row (the --- row) in the number of cells. If it doesn't, the table is not recognized and renders as plain text.
  • A pipe character inside a cell must be escaped with a backslash. An address like Unit 3 | Rear needs \|.
  • A row with fewer cells than the header gets empty cells, and extra cells are ignored. A missing postal code fails quietly, so count the cells when a row looks short.
  • Block-level elements cannot be inserted in a table, so keep every field on a single line.

Mail merge the list into envelope text

A mail merge is a template plus one row at a time. The template here is four lines: the name, the first address line, the second address line if there is one, and the city line. This short Python script reads the CSV and prints one block per household, skipping anyone already marked as sent:

import csv

with open("cards.csv", newline="", encoding="utf-8") as f:
    for row in csv.DictReader(f):
        if row["sent_2026"].strip():
            continue
        lines = [
            row["name"],
            row["line1"],
            row["line2"],
            row["city"] + ", " + row["region"] + " " + row["postal"],
        ]
        print("\n".join(line for line in lines if line.strip()))
        print()

Each block of output is ready to paste into a label tool or copy onto an envelope. A label printer or word processor is only needed for the physical layout, not for the merge itself. If you would rather skip code, add a column in your spreadsheet that joins the parts with line breaks, and copy that column out.

Handle blanks and duplicates

CSV carries no type information and does not distinguish a null value from an empty one, so a blank line2 is just an empty string. That is why the script tests with line.strip() and drops empty lines instead of printing a blank row in the middle of an address.

Before printing, sort the table by postal code or last name and look for repeated households. Two rows for the same address mean two cards in one mailbox. That's easy to spot in a sorted table and hard to spot in a raw CSV.

Keep the list for next December

Don't overwrite last year's flags. Next time, add a new sent_2027 column next time, so the file doubles as a record of who got a card in which year. Keep the CSV, the Markdown table, and the script in one folder, and regenerate the table from the CSV whenever the CSV changes so the two never drift apart. If you also plan the party side of the season, the holiday party checklist with a guest table uses the same plain-text approach.

Doing this with Carets

Carets is a fast, native notes and code editor for iPhone, iPad, and Mac. This workflow suits it because every piece is a plain text file. The CSV, the Markdown table, and the Python script all live as files in one project, so you can proofread the table, tweak a row, and edit the script without switching apps.

  • Markdown, plain text, and code in one editor. The CSV and table stay plain text, and the script gets syntax highlighting.
  • Files, projects, and tags. Keep a "holiday cards" project with the list, the script, and last year's copy side by side.
  • Native on iOS and Mac. Check addresses on your phone and finish the merge at your desk.

Your files stay plain text, so the list stays portable. Get Carets on the App Store for iPhone, iPad, and Mac.

Frequently Asked Questions

What columns should a holiday card address list have?

A practical set is name, address line 1, address line 2, city, region, postal code, country, and a column that records whether the card was sent. Keeping the parts separate lets you build the envelope lines in any order later. Blank cells are fine, since CSV does not distinguish empty from missing.

Why does my address land in two columns when I save the CSV?

An unquoted comma is read as a field separator. Per RFC 4180, a field containing a comma, a double quote, or a line break should be enclosed in double quotes, and a quote inside it is doubled. Most spreadsheet exports do this for you, so check the raw text if columns look shifted.

Why did my Markdown table stop rendering?

In GitHub Flavored Markdown the header row must have the same number of cells as the delimiter row, or the table is not recognized. An unescaped pipe in a cell also splits it in two. Escape a literal pipe with a backslash.

Do I need a mail merge app to print labels?

Not for the list itself. The merge is a template plus one row at a time, and a short script or a spreadsheet formula can produce the envelope text. A label-printing tool is only needed for the physical layout.