Python: How to read and handle a JSON file ver. 1

Last Updated on August 14, 2022 by shibatau

I. What will we learn?

We will learn how to read a JSON file and handle it with Class and Object.

II. Reading a sample CSV data set and save it as a JSON file with PANDAS

Here are the scripts:

# read CSV RAW data as a data framw with pandas
df = pd.read_csv('/content/sampleEnglishJapanesYerar2.csv')
#save it as a jason file
# load the json file and read it as a dictionary
import json
with open("/content/english_japanese.json", "r") as rf:
    decoded_data = json.load(rf)

Now show the dictionary:

You can handle the dictionary in a usual way:

You can see the scripts on Google Colaboratory:

III. Creating an Object

Not completed yet.

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.