Hi All,
I’ve just recently started using py-script to add some code to a website I’m making. The issue I’m running into is when I try to use the .read_json() function to read in a json file from a website, I get one of two errors.=:
The first error is: FileNotFoundError: File https%3A//www.atmos.albany.edu/student/abirnbaum/integral-protons-plot-1-day.json does not exist
This, I imagine, is due to me using urllib.parse for the quote() function in order to quote the url and change ‘https:’ to 'https%3A. However if I use the normal link with ‘https:’ I get: urllib.error.URLError: . I’ve put the python code below for people to take a look at. Any help is appreciated!
import pandas as pd
from pyscript import display
from urllib.parse import quote
url=‘https://www.atmos.albany.edu/student/abirnbaum/integral-protons-plot-1-day.json’
encodedurl=quote(url)
df = pd.read_json(encodedurl)
df = df.tail(4)
string=
flux = df[‘flux’].to_list()
energy = df[‘energy’].to_list()
for i in range(0, len(flux)):
flux[i] = str(round(flux[i], 3))
for i in range(0, len(flux)):
string.append(flux[i] + energy[i])
display(string)