0

I'm using DictWriter to write a dictionary to a csv after some geolocation work.

location = geolocator.reverse(coords)
row["address"] = location.address
writer.writerow(row)

Which generates this:

File "C:\bin64\python\3.4.3\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u200e' in
    position 118: character maps to <undefined>
Dissident Rage
  • 2,610
  • 1
  • 27
  • 33

1 Answers1

1

My problem was in how I was opening the file. I suppose I should have posted that in the question. I needed to set the encoding upon opening the file.

with open('results.csv', mode='w', encoding='utf-8', newline='') as file:
    ...
jfs
  • 399,953
  • 195
  • 994
  • 1,670
Dissident Rage
  • 2,610
  • 1
  • 27
  • 33