niran / merge-gmail-contacts

Automatically merges Google/Gmail contacts (or contacts exported from somewhere else in the same format) that have the same name.
3 stars 1 forks source link

KeyError: 'Name' #1

Closed benchun closed 14 years ago

benchun commented 14 years ago

Something's wrong...

$./merge_csv_contacts.py contacts.csv new-contacts.csv Traceback (most recent call last): File "./merge_csv_contacts.py", line 143, in process_row(row) File "./merge_csv_contacts.py", line 53, in process_row contact_name = row_data['Name'] KeyError: 'Name'

Here's my environment, just in case that's relevant:

$/usr/bin/env pythonPython 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information.

niran commented 14 years ago

Can you send me the first line of your csv file (i.e. the column names) and a couple of rows of contacts that you don't mind sharing?

benchun commented 14 years ago

I found out that Apple's address book application has a "find duplicates" feature so I ran that to great success. I'm now getting a different error:

$./merge_csv_contacts.py contacts.csv new-contacts.csv Traceback (most recent call last): File "./merge_csv_contacts.py", line 153, in process_emails(row) File "./merge_csv_contacts.py", line 83, in process_emails email, sec_one, sec_two = (row_data[col] for col in columns) File "./merge_csv_contacts.py", line 83, in email, sec_one, sec_two = (row_data[col] for col in columns) KeyError: 'E-mail'

I sent you some example data in a private message.

niran commented 14 years ago

For anyone else who runs into this: This was caused by a CSV file exported from GMail that had different column names than I had for some reason. He found another way to solve his problem, but if someone else runs into this, let me know and I might try to make it more flexible.

mikenotmike commented 14 years ago

I have the exact same issue, my column names are below...

The 1st line of my CSV file is..

Name,Given Name,Additional Name,Family Name,Yomi Name,Given Name Yomi,Additional Name Yomi,Family Name Yomi,Name Prefix,Name Suffix,Initials,Nickname,Short Name,Maiden Name,Birthday,Gender,Location,Billing Information,Directory Server,Mileage,Occupation,Hobby,Sensitivity,Priority,Subject,Notes,Group Membership,E-mail 1 - Type,E-mail 1 - Value,E-mail 2 - Type,E-mail 2 - Value,Phone 1 - Type,Phone 1 - Value,Phone 2 - Type,Phone 2 - Value,Phone 3 - Type,Phone 3 - Value,Phone 4 - Type,Phone 4 - Value,Address 1 - Type,Address 1 - Formatted,Address 1 - Street,Address 1 - City,Address 1 - PO Box,Address 1 - Region,Address 1 - Postal Code,Address 1 - Country,Address 1 - Extended Address,Address 2 - Type,Address 2 - Formatted,Address 2 - Street,Address 2 - City,Address 2 - PO Box,Address 2 - Region,Address 2 - Postal Code,Address 2 - Country,Address 2 - Extended Address,Organization 1 - Type,Organization 1 - Name,Organization 1 - Yomi Name,Organization 1 - Title,Organization 1 - Department,Organization 1 - Symbol,Organization 1 - Location,Organization 1 - Job Description

I tried changing it to just Name, but that didn't help.

any ideas?

daniel-sc commented 14 years ago

I have this issue as well and the same first line as in the post above

niran commented 14 years ago

Ok, I'll look into it this weekend. In the meantime, you might want to try the Apple Address Book contact merging mentioned above if you have a Mac available.

niran commented 14 years ago

Page rank boost for anyone who's trying to find out what a Yomi Name field in contacts is for.

Do both of you have contacts with non-latin characters in any fields?

mikenotmike commented 14 years ago

Thousands of contacts here, how would you recommend determining that?

niran commented 14 years ago

So it looks like Google exports two different formats. The type it exported to me dealt with multiple "types" of contact data (e.g. "Home", "Work", "Mobile", etc) by creating a "Section" for each type and including each field ("E-mail", "Phone", etc) in each section. The format it gave you two (and the one that makes more sense) deals with fields that can have multiple types individually, and it splits addresses into multiple fields.

Dealing with the format Google gave you guys would require rewriting most of the script, and since there's an easy alternative (Address Book, which I would've used instead of writing the script in the first place if I'd known about it), it doesn't seem worth doing.

mikenotmike commented 14 years ago

Understandable, can you link to address book, not sure I've seen it...

niran commented 14 years ago

It comes with OS X.

http://www.apple.com/macosx/what-is-macosx/mail-ical-address-book.html

mikenotmike commented 14 years ago

ahh. XP here, of course.. Thanks for following up either ay

daniel-sc commented 14 years ago

thanks for your attention. guess i have non-latin characters..