MCPcopy Create free account
hub / github.com/dabeaz-course/practical-python / read_prices

Function read_prices

Solutions/3_2/report.py:25–38  ·  view source on GitHub ↗

Read a CSV file of price data into a dict mapping names to prices.

(filename)

Source from the content-addressed store, hash-verified

23 return portfolio
24
25def read_prices(filename):
26 '''
27 Read a CSV file of price data into a dict mapping names to prices.
28 '''
29 prices = {}
30 with open(filename) as f:
31 rows = csv.reader(f)
32 for row in rows:
33 try:
34 prices[row[0]] = float(row[1])
35 except IndexError:
36 pass
37
38 return prices
39
40def make_report_data(portfolio,prices):
41 '''

Callers 1

portfolio_reportFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected