Open
Conversation
sjdonado
commented
Apr 15, 2023
| import csv | ||
| import json | ||
|
|
||
| default_input_file_format = { |
Author
There was a problem hiding this comment.
This aids readability, makes the supported keys visible
sjdonado
commented
Apr 15, 2023
| 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: |
Author
There was a problem hiding this comment.
removes the BOM character prefix if exists
sjdonado
commented
Apr 15, 2023
| 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) |
Author
There was a problem hiding this comment.
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
sjdonado
commented
Apr 15, 2023
| i = 0 | ||
| for row in reader: | ||
|
|
||
| FN_VAL = row[FN] if FN is not None else '' |
Author
There was a problem hiding this comment.
new logic for building the FN_VAL based on the full_name or first_name + last_name pair
sjdonado
commented
Apr 15, 2023
| convert_to_vcard(input_file, single_output, input_file_format) | ||
|
|
||
| print('\033[92m'+"DONE"+'\033[0m') | ||
| print("Output files are in `csv2vcf` folder") |
Author
There was a problem hiding this comment.
when generating output files it is always useful to print the path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of all, thanks for the script, it saved my day!
I used it to export the
contacts.csvfile returned by Outlook :) Here are some suggestions/fixes