8000 Fix read mode and Python2 .next() call · 2cans/python-basics-exercises@b02b25c · GitHub
[go: up one dir, main page]

Skip to content

Commit b02b25c

Browse files
committed
Fix read mode and Python2 .next() call
1 parent 69ccda6 co
8000
mmit b02b25c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ch16-scientific-computing-and-graphing/2-use-matplotlib-for-plotting-graphs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
import os
99

1010
# Change `path` to actual path on your system
11-
path = "C:/python-basics-exercises/ch16-scientific-computing-and-graphing/\
12-
practice_files"
11+
path = "C:/Real Python/python-basics-exercises/ch16-scientific-computing-and-graphing/\
12+
practice_files"
1313

1414
years = []
1515
temperatures = []
1616
pirates = []
1717

18-
with open(os.path.join(path, "pirates.csv"), "rb") as my_file:
18+
with open(os.path.join(path, "pirates.csv"), "r") as my_file:
1919
my_file_reader = csv.reader(my_file)
20-
my_file_reader.next() # skip header row
20+
next(my_file_reader) # skip header row
2121
for year, temperature, pirate_count in my_file_reader:
2222
years.append(year)
2323
temperatures.append(temperature)
@@ -36,5 +36,5 @@
3636
plt.annotate(str(years[i]), xy=(pirates[i], temperatures[i]))
3737

3838
# save and display graph
39-
plt.savefig(os.path.join(path, "Output/pirates.png"))
39+
# plt.savefig(os.path.join(path, "Output/pirates.png"))
4040
plt.show()

0 commit comments

Comments
 (0)
0