import os dirPath = os.path.dirname(os.path.realpath(__file__)) responses = [] # Our dictionaries go in here. with open(dirPath + '/core_trends.csv', 'r') as file: headers = file.readline() # Read the headers headers = headers.strip().split(',') # Make a list from headers for line in file: # Iterate through rest of file line = line.strip().split(',') # Split line r = {} for i in range(len(headers)): r[headers[i]] = line[i] responses.append(r) instaYes = 0 instaNo = 0 for r in responses: if r['web1b'] == '1': instaYes += 1 elif r['web1b'] == '2': instaNo += 1 else: continue print(instaYes / len(responses)) print(instaNo / len(responses))