@@ -0,0 +1,1229 @@
+import os%0Aimport json%0Afrom pandas import DataFrame%0A%0Adef download_data_model():%0A    model_file = os.path.join('3_0', 'MagIC Data Model v3.0 - unpublished.json')%0A    f = open(model_file, 'r')%0A    string = '%5Cn'.join(f.readlines())%0A    raw = json.loads(unicode(string, errors='ignore'))%0A    full = DataFrame(raw)%0A    return full%0A%0Adef parse_data_model(full_df):%0A    data_model = %7B%7D%0A    levels = %5B'specimens', 'samples', 'sites', 'locations'%5D%0A    for level in levels:%0A        df = DataFrame(full_df%5B'tables'%5D%5Blevel%5D%5B'columns'%5D)%0A        data_model%5Blevel%5D = df.transpose()%0A    return data_model%0A%0A%0Adef get_data_model():%0A    full_df = download_data_model()%0A    return parse_data_model(full_df)%0A%0A%0ADATA_MODEL = get_data_model()%0A#%0A%0Adef get_groups(table_name):%0A    %22%22%22%0A    Return list of all groups for a particular data type%0A    %22%22%22%0A    df = DATA_MODEL%5Btable_name%5D%0A    return list(df%5B'group'%5D.unique())%0A%0A%0Adef get_headers(table_name, group_name):%0A    %22%22%22%0A    Return a list of all headers for a given group%0A    %22%22%22%0A    # get all headers of a particular group%0A    df = DATA_MODEL%5Btable_name%5D%0A    cond = df%5B'group'%5D == group_name%0A    return df%5Bcond%5D.index%0A%0A%0A%0Aif __name__ == %22__main__%22:%0A    dm = get_data_model()%0A    print dm%5B'specimens'%5D.index%0A%0A%0A

add module for dealing with 3.0 data_model