def parse_file datafile data count with open datafile rb as titles rea

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def parse_file(datafile):
data = []
count = 0
with open(datafile, "rb") as f:
titles = f.readline().split(",")
print titles
item = []
for line in f:
item.append({title: value for title, value in titles, line.split(",")})
count += 1
if count == 10:
return data
data.append(dict(item))