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

Function read_portfolio

Solutions/3_18/report.py:5–11  ·  view source on GitHub ↗

Read a stock portfolio file into a list of dictionaries with keys name, shares, and price.

(filename)

Source from the content-addressed store, hash-verified

3import fileparse
4
5def read_portfolio(filename):
6 '''
7 Read a stock portfolio file into a list of dictionaries with keys
8 name, shares, and price.
9 '''
10 with open(filename) as lines:
11 return fileparse.parse_csv(lines, select=['name','shares','price'], types=[str,int,float])
12
13def read_prices(filename):
14 '''

Callers 1

portfolio_reportFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected