MCPcopy Index your code
hub / github.com/dabeaz-course/practical-python / read_prices

Function read_prices

Solutions/2_11/report.py:24–37  ·  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

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

Callers 1

report.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected