#data analysis

#we'll use the ice cream flavor rankings you gave us on midterm 2
#what's our goal? maybe to find the most popular flavor of ice cream?
#what is popular?
#   counts of #1 choice?
#   count over any choice?
#   weighted count where 1's place is 3pts, 2nd is 2pts, 3rd is 1pt?

#each line in the file is a person's ice cream preference
#if nothing was filled in, the line is blank


"""
Data Analysis: using csv to import the file
"""
import csv

#open the file the same way
f = open("icecreams.csv","r")
#tell the csv reader to use the file and split the lines with ","
csvreader = csv.reader(f,delimiter=",")

#put all the data in a 2D list
preferences= []
for row in csvreader:
    preferences.append(row)

#get the header, which was the first line in the file
column_list = preferences[0]
#remove the header from the data
preferences.pop(0)


'''
Data Summarization:
'''
#count how many lines in the data
def countRows(preflist):
    return 0

print("Count Rows: "+str(countRows(preferences)))

#how many rows have ANYTHING in them (other than id)
def countHasAtLeast1Pref(preflist):
    return 0

print("Count non-blank rows: "+str(countHasAtLeast1Pref(preferences)))

#how many rows have all three values filled in
#only difference is and's instead of or's
def countHasAllPrefs(preflist):
    return 0

print("Count filled all prefs: "+str(countHasAllPrefs(preferences)))

#count of many of each top preference
def countTopPreferences(preflist):
    prefcount = {}
    return prefcount

print("Counts of all preferences: "+str(countTopPreferences(preferences)))

'''
Machine Learning: make predictions about what comes next in preferences
'''
#choose a random first preference out of all first preferences
def chooseUniformRandomPref(prefcount):
    import random
    return 0

#choose a random top choice
print("Random top preference:  "+str(chooseUniformRandomPref(countTopPreferences(preferences))))

#choose a first preference based on the probability of it being chosen by the class
def chooseWeightedRandom(prefcount):
    import random
    return 0

print("Random weighted top preference: "+str(chooseWeightedRandom(countTopPreferences(preferences))))

