'I am trying to retrieve rick and morty json data from the website and I keep getting this error: "NameError: name 'null' is not defined"
When I try to run the following code using Spark (databricks) in python code:
from urllib import request as url
request = url.Request('https://rickandmortyapi.com/api/character/')
Rick = eval(
url.urlopen(request).read().decode('utf-8').strip()
)
# convert to a dataframe
Morty = spark.createDataFrame(Rick)
display(Morty)
I get an error message that says:
NameError: name 'null' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<command-2109831538106701> in <module>
4 # retrieve json data from website
5 request = url.Request('https://rickandmortyapi.com/api/character/')
----> 6 Rick = eval(
7 url.urlopen(request).read().decode('utf-8').strip()
8 )
<string> in <module>
NameError: name 'null' is not defined
How do I fix this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
