Categories

Saturday, April 20, 2024
#919814419350 therichposts@gmail.com
Python

How to read the json file in python 3.9.6 and print it in table format with pandas?

How to read the json file in python 3.9.6 and print it in table format with pandas?

Hello guy’s welcome back to my blog. Today in this blog post, I will tell you, How to read the json file in python 3.9.6 and print it in table format with pandas?

Guy’s in this post, I have used python 3.9.6 version.

Working Video
How to read the json file in python 3.9.6 and print it in table format with pandas?
How to read the json file in python 3.9.6 and print it in table format with pandas?

Here is the working video for how to install pandas in python 3.9.6:

Install pandas in python

Guy’s if you are new in Python then please check below link for more Python tutorials:

  1. Python Tutorials

Guy’s here is the working code snippet and please use it carefully:

1. Guy’s very first we need to installed python latest version and I have installed python 3.9.6 version. From below link please download the python latest version:

https://www.python.org/downloads/

2. Now guy’s create empty folder name `demo`(optional) in your system’s any drive and inside demo folder create `HelloWorld.py` and add below code inside it:

# Python program to read
# json file
  
  
import json
import pandas as pd #for install pandas in python please see above second video
# Opening JSON file
f = open('data.json',)

data = json.load(f)
  
df = pd.DataFrame(data)

#print json data in table format
print(df)

# Closing file
f.close()

3. Guy’s also in your project `demo` folder please create data.json file and add below code inside it:

[
    {
        "id": "1",
        "name": "Harjas Malhotra",
        "email": "harjas@gmail.com",
        "job_title": "CEO&Founder",
        "created_at": "2021-01-31 00:07:38",
        "updated_at": "2021-01-31 00:07:38"
    },
    {
        "id": "2",
        "name": "Ajay Rich",
        "email": "therichposts@gmail.com",
        "job_title": "Full Stack Developer",
        "created_at": "2021-01-29 11:36:14",
        "updated_at": "2021-01-29 11:36:14"
    }
]

4. Now guy’s inside your project terminal run below command and run your first python program:

py HelloWorld.py

This is it guy’s. Guy’s if you have any kind of query then please comment below. Guy’s I will come with more demos soon.

For better live working experience please check the above working video.

I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad because with your views, I will make my next posts more good and helpful.

Jassa

Thanks

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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