Hello guy’s welcome back to my blog. Today in this blog post, I will tell you, Python 3 Read and Print API JSON Data in Table Format.
Guy’s in this post, I have used python 3.9.6 version.
Here is the working video for how to install pandas in python 3.9.6:
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:
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:
import json import pandas as pd from urllib.request import urlopen # store the URL in url as # parameter for urlopen url = "https://www.testjsonapi.com/users/" # store the response of URL response = urlopen(url) # Opening JSON file #f = open(response.read()) # returns JSON object as # a dictionary data = json.loads(response.read()) df = pd.DataFrame(data) print(df) # Closing file response.close()
3. Now guy’s inside your project terminal run below command and run your first python program:
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.