Working with JSON on COLAB

Working with JSON on COLAB

# load the remote data into a Pandas DataFrame
import pandas as pd
df = pd.read_json('https://archive.org/download/crowdflower/text_emotion.json', encoding='latin-1')
df

see colab example

Get JSON from upload object and load into pandas data frame

# using upload object to upload json
from google.colab import files
import pandas as pd
import io

uploaded = files.upload()
# assume that the user uploaded only one file
# and the file is a json format
df = pd.read_json(io.StringIO(uploaded[list(uploaded.keys())[0]].decode('utf-8')))
df

see colab example