My dad called me today with an emergency: his phone stopped working, he took it to Verizon, they couldn’t fix it and his only option was to purchase a brand new phone, a Samsung Galaxy J3. He never backed up his phone contacts to the cloud, and the only backup he had was a folder with .0 files.

I tried opening the files in Sublime text, but they were binary. I then tried reading them in Python, where the output was a bit more promising:


I then proceeded to fire up PyCharm and wrote a quick script to create a Google CSV file which could be imported into his new Gmail account.

import os
import csv
import re

csv_output = '/Users/eugenegekhter/dev/contacts.csv'
file_loc = '/Users/eugenegekhter/dev/contacts'

def organize_data():
    tmp_data = os.listdir(file_loc)
    output_list = []
    file_re = '(\d{10,11})'
    for f in tmp_data:
        if not f.count('-'):
        if f.count('-') == 2:
            name_re = '(.*)-(.*)-'
            name_re = '(.*)-()'
        tmp_dict = {}
        m = re.match(name_re, f)
        first_name =
        last_name =
        tmp_dict["first_name"] = first_name
        tmp_dict["last_name"] = last_name

        tmp_file = os.path.join(file_loc, f)

        with open(tmp_file) as ff:
            tmp_c =
            tmp_phone =, tmp_c)
            if tmp_phone is not None:
                tmp_dict["phone"] =

    return output_list

def write_csv(data):
    with open(csv_output, 'w') as csvfile:
        fieldnames = ['Name', 'Given Name', 'Phone 1 - Type', 'Phone 1 - Value']
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

        for contact in data:
            writer.writerow({'Name': contact['first_name'], 'Given Name': contact['last_name'],
                             'Phone 1 - Type': 'Home', 'Phone 1 - Value': contact['phone']})

organized_data = organize_data()

Voila, 30 minutes later, all my dad’s contacts had been saved and available on his new Android phone.

Read more