No description
Find a file
2025-12-16 14:13:53 -08:00
test Moved test support files to test subdir 2025-12-16 14:13:53 -08:00
.gitignore Moving package from LabelNation to gLabels. 2024-12-14 18:13:27 -08:00
process_contacts.py Some cleanups. Added test case to run the script with sample data. 2025-12-16 14:05:05 -08:00
README.md Moved test support files to test subdir 2025-12-16 14:13:53 -08:00
UNLICENSE.TXT Minor doc tweaks. 2025-12-13 16:52:58 -08:00

mk-labels-from-contacts

Generate mailing label data from a Google Contacts export.

The input is a CSV file, produced by Google Contacts export.

The output is a CSV file that can be consumed by tools such as the gLabels label printer.

Example:

python3 process_contacts.py < contacts.csv > labels.csv

In this example contacts.csv is the export from Google Contacts, and labels.csv will be imported into the utility you use for mail merge.

Process

There are three steps to making your labels:

  1. Export selected contacts from Google Contacts to a CSV file
  2. Run process_contacts.py on the exported CSV file
  3. Generate labels from the processed contacts

Export Contacts

These directions are for the web version of Google Contacts. We'll setup a group to contain all the contacts we want to make labels for.

Make the group:

  • Select all the contacts you want to export.
  • Click the "Manage Labels" icon at the top.
  • Select "Create Label" and give the group a name.

Export the group:

  • Click the "..." icon at the top and select "Export".
  • Choose "Export selected contacts".
  • Choose "Export as Google CSV".
  • Click "Export" and save to a local file (default "contacts.csv").

Using gLabels

To generate address labels using gLabels, once you have run process_contacts.py, do:

  • Create a new project with your selected label type
  • Select: Object -> Merge Properties
    • set format: CSV with keys
    • select Location: labels.csv
  • In the label design, select a text box that fills the label

In the label text box, enter as your template:

${F1}
${F2}
${F3}
${F4}

FAQ

How do I make an address with multiple recipients?

Use the "Related Person" field to add a second recipient, with one of the following relation types: Spouse, Partner, Domestic Partner, or Fiancee. Only the first related person listed will be considered.

How well does this work with international addresses?

Poorly. US and Canadian addresses work ok, but otherwise no promises.

Is there sample data I can test on?

Yes. There is an example Google Contacts export in: example-contacts.csv

What results from processing the example-contacts.csv file?

It should look like example-labels.csv.

Can I generate sample data with 37 addresses?

Yes. You may wish to do this if the provided example-contacts.csv does not include sufficient addresses for your testing.

Run:

pip install Faker
python3 test/mk-example-contacts.py --num-entries 37 >whatever.csv

Are there test cases?

Yes. Run:

pip install pytest
pytest -v test

Author

Courtney Rosenthal
cr@crosenthal.com