-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First Name + Last Name support #4
base: master
Are you sure you want to change the base?
Conversation
@@ -10,28 +10,51 @@ | |||
import csv | |||
import json | |||
|
|||
default_input_file_format = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This aids readability, makes the supported keys visible
with open( input_file, 'r' ) as source_file: | ||
reader = csv.reader( source_file ) | ||
if single_output: | ||
with open(input_file, 'r', encoding='utf-8-sig') as source_file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removes the BOM character prefix if exists
reader = csv.reader( source_file ) | ||
if single_output: | ||
with open(input_file, 'r', encoding='utf-8-sig') as source_file: | ||
reader = csv.DictReader(source_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The csv
file generated by Outlook contains tons keys:
First Name | Middle Name | Last Name | Title | Suffix | Nickname | Given Yomi | Surname Yomi | E-mail Address | E-mail 2 Address | E-mail 3 Address | Home Phone | Home Phone 2 | Business Phone | Business Phone 2 | Mobile Phone | Car Phone | Other Phone | Primary Phone | Pager | Business Fax | Home Fax | Other Fax | Company Main Phone | Callback | Radio Phone | Telex | TTY/TDD Phone | IMAddress | Job Title | Department | Company | Office Location | Manager's Name | Assistant's Name | Assistant's Phone | Company Yomi | Business Street | Business City | Business State | Business Postal Code | Business Country/Region | Home Street | Home City | Home State | Home Postal Code | Home Country/Region | Other Street | Other City | Other State | Other Postal Code | Other Country/Region | Notes | Personal Web Page | Spouse | Schools | Hobby | Location | Web Page | Birthday | Anniversary
Indexing by key titles is more convenient
single_vcf = open('csv2vcf/all_contacts.vcf', 'w') | ||
i = 0 | ||
for row in reader: | ||
|
||
FN_VAL = row[FN] if FN is not None else '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new logic for building the FN_VAL based on the full_name
or first_name
+ last_name
pair
os.makedirs('csv2vcf') | ||
|
||
convert_to_vcard(input_file, single_output, input_file_format) | ||
|
||
print('\033[92m'+"DONE"+'\033[0m') | ||
print("Output files are in `csv2vcf` folder") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when generating output files it is always useful to print the path
First of all, thanks for the script, it saved my day!
I used it to export the
contacts.csv
file returned by Outlook :) Here are some suggestions/fixes