"""
Learning Goals - Data Analysis
 - Understand what data analysis is and where it is used
 - Recognize and load common data formats (like CSV and JSON) into code
 - Run basic functions to analyze data in python
"""

### First approach: parse by hand ###
f = open("icecreams.csv", "r")

# Get the header
header = f.readline().strip()
columns = header.split(",")

prefs = [ ]
for line in f:
    values = line.strip().split(",")
    prefs.append(values)
print(prefs)

### Second Approach: parse with csv module ###
import csv
f = open("icecreams.csv", "r")
reader = csv.reader(f, delimiter=",")

prefs = []
for row in reader:
    prefs.append(row)

columns = prefs[0]
prefs.pop(0)

print(prefs)

### Third Approach: load to a pandas dataframe ###
import pandas as pd

df = pd.read_csv("icecreams.csv", delimiter=",")

print(df)

for index, row in df.iterrows():
    print(row['Flavor 1'])