ex2.2 part 1

This commit is contained in:
Mike Bloy 2023-10-09 16:58:49 -05:00
parent 76e3381760
commit e80cfbc2f9

16
readport.py Normal file
View File

@ -0,0 +1,16 @@
import csv
def read_portfolio(filename):
portfolio = []
with open(filename) as f:
rows = csv.reader(f)
headers = next(rows)
for row in rows:
record = {
'name': row[0],
'shares': int(row[1]),
'price': float(row[2])
}
portfolio.append(record)
return portfolio