Family

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.

contact-list
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:

android-contacts-python

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('-'):
            continue
        if f.count('-') == 2:
            name_re = '(.*)-(.*)-'
        else:
            name_re = '(.*)-()'
        tmp_dict = {}
        m = re.match(name_re, f)
        first_name = m.group(1)
        last_name = m.group(2)
        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 = ff.read()
            tmp_phone = re.search(file_re, tmp_c)
            if tmp_phone is not None:
                tmp_dict["phone"] = tmp_phone.group(1)
                output_list.append(tmp_dict)

    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)

        writer.writeheader()
        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()
write_csv(organized_data)
 

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

Read more

Edgar and I shared a first on May 29th, 2016 – it was our very first trip to a zoo! As excited as Edgar was to see all the new animals, I could not stop saying “wow” and “woah” the entire time during our trip. My parents felt bad because they realized they had not taken me in 33 years so my dad picked up the tab as a way to compensate 🙂 No complaints from me!

A timeline of our pictures at the zoo on Memorable!

A timeline of our pictures at the zoo on Memorable!

Read more