MCPcopy Create free account
hub / github.com/dabeaz-course/python-mastery / read_portfolio

Function read_portfolio

Solutions/2_2/readport.py:6–18  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

4
5# A function that reads a file into a list of dicts
6def read_portfolio(filename):
7 portfolio = []
8 with open(filename) as f:
9 rows = csv.reader(f)
10 headers = next(rows)
11 for row in rows:
12 record = {
13 'name' : row[0],
14 'shares' : int(row[1]),
15 'price' : float(row[2])
16 }
17 portfolio.append(record)
18 return portfolio

Callers

nothing calls this directly

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected