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