Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for UnicodeDecodeError #12

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/csv.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ To get you started, on the OpenFlights web page it shows that "Name" is the seco
Here's some code that prints the name of every airport:

import csv
f = open("airports.dat")
f = open("airports.dat", encoding="utf-8")
for row in csv.reader(f):
print(row[1])

Expand All @@ -64,7 +64,7 @@ Can you expand on that to only print airports for a certain country?
## Solution

import csv
f = open("airports.dat")
f = open("airports.dat", encoding="utf-8")
for row in csv.reader(f):
if row[3] == "Australia" or row[3] == "Russia":
print(row[1])
Expand Down Expand Up @@ -101,7 +101,7 @@ Look back at the [OpenFlights data page](http://www.openflights.org/data.html) t

latitudes = {}
longitudes = {}
f = open("airports.dat")
f = open("airports.dat", encoding="utf-8")
for row in csv.reader(f):
airport_id = row[0]
latitudes[airport_id] = float(row[6])
Expand Down Expand Up @@ -154,7 +154,7 @@ When looking at the list of fields in the OpenFlights data documentation, rememb
## Solution

distances = []
f = open("routes.dat")
f = open("routes.dat", encoding="utf-8")
for row in csv.reader(f):
source_airport = row[3]
dest_airport = row[5]
Expand Down