from pathlib import Path
import pickle


def read_pickle_dict(filename, folder='C:/Users/Avram/Dropbox (MIT)/MIT'
                     '/Research/Thesis/Sections/mod_studies/'):
    """Read ptrac data dictionary from pickle file."""
    if folder == '':
        folder = Path.cwd()    # set folder ='' to use current directory
    path = Path(folder, filename).with_suffix('.pkl')
    try:
        print(f'Reading {path}...')
        with open(path, 'rb') as f:
            data = pickle.load(f)
    except IOError:
        print('Pickle file not found.')
        data = {}
    return data