Skip to content

Commit

Permalink
work around python 2 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Apr 12, 2017
1 parent 463b933 commit ae61fdd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions py/desiutil/census.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,14 @@ def output_csv(summary, filename):
row.append(str(number[d][y]))
row.append(str(size[d][y]))
data.append(row)
with open(filename, 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerows(data)
try:
csvfile = open(filename, 'w', newline='')
except TypeError:
# Python 2
csvfile = open(filename, 'w')
writer = csv.writer(csvfile)
writer.writerows(data)
csvfile.close()
return data


Expand Down

0 comments on commit ae61fdd

Please sign in to comment.