Importing first and last name from Mail

The official docs for migrating an mailing list from Mailchimp primarily address importing the email address.

One thing they don’t address is that MailChimp has a “first_name” and “last_name” field, while the Ghost importer expects only a “Name” field.

Here’s how I imported both the first the and last name from MailChimp into Ghost’s “Name” column.

Looking at the MailChimp exported CSV, I saw that the first_name field was the second column and the last_name was in the third column. Using Perl, I replaced the second column on each line with a space, effectively joining the two columns.

perl -pe 's/^(.*?,.*?),/$1 /' export.csv>merged-names.csv

Because the header row quoted the column names, I also needed to open the resulting doc in a text editor (not a spreadsheet tool) a final time to fix that quoting:

# before
"first_name" "last_name"
# after
"Name"

Now that the first and last name were in a single column, I could easily match this column up with Ghost’s Name column during import.