diff --git a/stock.py b/stock.py index 1fb01ca..3ed2ee0 100644 --- a/stock.py +++ b/stock.py @@ -1,3 +1,6 @@ +import csv + + class Stock: def __init__(self, name, shares, price): self.name = name @@ -11,3 +14,10 @@ class Stock: self.shares -= num if self.shares < 0: self.shares = 0 + + +def read_portfolio(filename): + with open(filename) as f: + rows = csv.reader(f) + _ = next(rows) + return [Stock(row[0], row[1], row[2]) for row in rows]