Skip to content

Instantly share code, notes, and snippets.

@PrasadNR
PrasadNR / phoneCountryCode.py
Created January 11, 2020 19:17
Automatically add country code to phone numbers in vCalendar File wherever that is absent (I wrote it after moving to USA from India). Minor changes may be needed for different cases/countries/versions of VCF. As I only found paid apps for this, I wrote this one after analysing patterns for about 2 hours.
import re
with open('PIM00004.vcf', 'r') as f:
vcfText = f.read()
regex = re.compile(r'[0-9-]+')
regexPhoneNumbers = regex.findall(vcfText)
for eachRegexPhoneNumber in regexPhoneNumbers: