MCPcopy Index your code
hub / github.com/dabeaz-course/python-mastery / read_portfolio

Function read_portfolio

Solutions/3_3/stock.py:21–33  ·  view source on GitHub ↗

Read a CSV file of stock data into a list of Stocks

(filename)

Source from the content-addressed store, hash-verified

19 self.shares -= nshares
20
21def read_portfolio(filename):
22 '''
23 Read a CSV file of stock data into a list of Stocks
24 '''
25 import csv
26 portfolio = []
27 with open(filename) as f:
28 rows = csv.reader(f)
29 headers = next(rows)
30 for row in rows:
31 record = Stock.from_row(row)
32 portfolio.append(record)
33 return portfolio
34
35if __name__ == '__main__':
36 import tableformat

Callers

nothing calls this directly

Calls 2

appendMethod · 0.80
from_rowMethod · 0.45

Tested by

no test coverage detected