Skip to content

Commit ac263a5

Browse files
committed
Exercise 2.4
1 parent 4d87202 commit ac263a5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Work/report.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
# report.py
22
#
33
# Exercise 2.4
4+
5+
import csv
6+
7+
def read_portfolio(filename):
8+
'''Computes the total cost (shares*price) of a portfolio file'''
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+
nshares = int(row[1])
16+
price = float(row[2])
17+
portfolio.append((row[0], nshares, price))
18+
return portfolio
19+
20+

0 commit comments

Comments
 (0)