def fileTOdictionary(filename):
    """ This function takes a file and converts it to a sparse matrix nested dictionary, [age][icd_column_number]."""
    fh = open(filename)
    header = next(fh)
    data_dict = {}
    numlist = range(1,36)
    for line in fh:
        line = line.strip().split(",")
        for x in numlist:
            #dictionary below has the following structure
            #{"0":{"1":datavalue, "2":dataValue....}, "2.5":{"1":datavalue, "2":dataValue....}}
            #So we have the key being the age, and the value being a nested dict with the key being the ICD column number and the value being the number from the data set
            if str(line[4]) not in data_dict:
                data_dict[str(line[4])] = {}
                data_dict[str(line[4])][str(x)] = line[x+8]
            else:
                data_dict[str(line[4])][str(x)] = line[x+8]
    print(data_dict)
    return data_dict