Skip to content

Commit 076b6b9

Browse files
authored
Update report.py
1 parent 0c0918c commit 076b6b9

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎Work/report.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
# report.py
22
#
33
# Exercise 2.4
4+
import csv
5+
6+
def read_portfolio(filename):
7+
'''Opens a given portfolio file and reads it into a list of tuples'''
8+
9+
portfolio = []
10+
11+
with open(filename, 'rt') as f:
12+
rows = csv.reader(f)
13+
headers = next(rows)
14+
for row in rows:
15+
holding = (row[0], int(row[1]), float(row[2]))
16+
portfolio.append(holding)
17+
return portfolio

0 commit comments

Comments
 (0)