0

I have been developing in detail all the small projects found on the Python Crash Course 3d Edition book and on the section Examining GeoJSON Data I am having this error:

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 32173: character maps to

I did it on PyCharm and Geany but it did not work

///I tried this:///

from pathlib import Path
import json

# Read data as a string and convert to a Python object.
path = Path('eq_data/eq_data_1_day_m1.geojson')
contents = path.read_text()
all_eq_data = json.loads(contents)

# Create a more readable version of the data file.
path = Path('eq_data/readable_eq_data.geojson')
readable_contents = json.dumps(all_eq_data, indent=4)
path.write_text(readable_contents)

///And was expecting a new fiel with a more readable format:///

expected image

  • Your question lacks debugging details. Often, this happens because you are on Windows and try to print Unicode to a terminal which is only set up to handle some 8-bit encoding like cp1252. – tripleee Jan 25 '23 at 05:56
  • Thanks, I tried it on Linux and there was no problem! – user215072 Jan 26 '23 at 04:26

0 Answers0