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

Method from_csv

Solutions/8_1/portfolio.py:11–21  ·  view source on GitHub ↗
(cls, lines, **opts)

Source from the content-addressed store, hash-verified

9
10 @classmethod
11 def from_csv(cls, lines, **opts):
12 self = cls()
13 portdicts = fileparse.parse_csv(lines,
14 select=['name','shares','price'],
15 types=[str,int,float],
16 **opts)
17
18 for d in portdicts:
19 self.append(stock.Stock(**d))
20
21 return self
22
23 def append(self, holding):
24 self._holdings.append(holding)

Callers 1

read_portfolioFunction · 0.45

Calls 1

appendMethod · 0.95

Tested by

no test coverage detected