0

The json file:

I have a large json file and I wrote a program to draw with its data:

import plotly.express as px
import pandas as pd
import json

filename = 'eq_data_1_day_m1.json'
with open(filename,encoding = "utf-8") as f:
    all_eq_data = json.load(f)
    
all_eq_dicts = all_eq_data['features']    
mags,titles,lons,lats = [],[],[],[]
for eq_dict in all_eq_dicts:
    mag = eq_dict['properties']['mag']
    title = eq_dict['properties']['title']
    lon = eq_dict['geometry']['coordinates'][0]
    lat = eq_dict['geometry']['coordinates'][1]
    mags.append(mag)
    titles.append(title)
    lons.append(lon)
    lats.append(lat)

#print(mags[:5])
#print(titles[:5])
#print(lons[:5])
#print(lats[:5])


fig = px.scatter(
    x = lons,
    y = lats,
    range_x=[-200,200],
    range_y=[-90,90],
    width=800,
    height=800,
    title = 'global_earthquakes'
)

fig.write_html('global_earthquakes.html')
fig.show()

Then the vscode said it has a UnicodeDecodeError:

UnicodeDecodeError
'utf-8' codec can't decode byte 0xd7 in position 0: invalid continuation byte
  File "C:\Users\asus\Desktop\Python_learning\lesson16\eq_explore_date.py", line 38, in <module>
    fig.show()

How can I solve this problem?

tdelaney
  • 63,514
  • 5
  • 71
  • 101
  • https://stackoverflow.com/questions/5552555/unicodedecodeerror-invalid-continuation-byte Check this link – sa_n__u Jul 23 '21 at 04:54

0 Answers0