[Python Programming Basics to Advanced] JSON data parsing in Python

preview_player
Показать описание
In this lesson we will study about the JSON data format and parsing that with Python. It is the most widely used Data Format at present. Python has json library or module to read the JSON data as Python Dictionary. We will cover these things:
What is JSON : 00:00
JSON Format : 03:23
JSON to Python Dictionary : 04:05
Python Dictionary to JSON : 13:50
Periodic Table Example: 19:33
Importing JSON data from Web Server API : 26:49
Quran Example : 34:18

Python Documentation:

Example Files used:

Periodic Table JSON data link:

Public APIs dataset:

Quran API:

Lesson on Dictionary:

Lesson on Text Files:

Lesson on CSV files:

Lesson on Map and Filter:

Complete Playlist:

If you have the basic programming knowledge and interested to learn Object-Oriented Programming in Python, check out this playlist:

Review Questions:
1- Given at 26:39
2&3- Given at 37:22

#PythonProgramming
Рекомендации по теме
Комментарии
Автор

1:

fil=filter(lambda a:a['category']=='alkali metal', data['elements'])
print(list(map(lambda b:b['symbol'], f)))


2:


sor=sorted(data['chapters'], key=lambda a:a['revelation_order'])
print(list(map(lambda b:b['name_simple'], s)))

3:

print(reduce(lambda a, b:a+b['verses_count'], data['chapters'], 0))

AliIrfan-soxf
Автор

Q1):
l=[i["symbol"] for i in data['elements'] if i["category"]=="alkali metal"]
print(l)
Q2):
x=sorted(data["chapters"], key=lambda a:a["revelation_order"])
l=list(map(lambda y:y['name_simple'], x))
print(l)
Q3):
print(reduce(lambda x, y:x+y["verses_count"], data['chapters'], 0))

yusrakashif
Автор

1)
a = list(filter(lambda s:s['shells'][-1]==1and s['category']=='alkali metal', a['elements']))
b = list(map(lambda s:s['symbol'], a))
print(b)
2)
s = sorted(a['chapters'], key = lambda s:s['revelation_order'])
a = list(map(lambda s:s['name_simple'], s))
print(a)
3)
a = list(map(lambda s:s['verses_count'], a['chapters']))
print(sum(a))

ahmedimran
Автор

1)x=filter(lambda m:m['ctgry']=='alkalis', data['element'])
print(list(map(lambda n:n['symbol'], x)))
2)x=sorted(data['chap'], key=lambda a:a['order'])
print(list(map(lambda b:b['name_simple'], x)))
3)print(reduce(lambda x, y:x+y['verses_count'], data['chap'], 0)

zainzakir
Автор

Q-1
x=[(i['name_simple'], i['revelation_order']) for i in data['chapters']]
print([j[0] for j in (sorted(x, key=lambda x:x[1]))])
Q-2
from functools import reduce
print(reduce(lambda x, y: x + y["verses_count"], data['chapters'], 0))
#0 is initializer to keep x as an int and y['verses_count'] as dict

muhammadshess
Автор

Q no 1

l=[i["symbol"] for i in data['elements'] if i["category"]=="alkali metal"]
print(l)


Q no 2


x=sorted(data["chapters"], key=lambda a:a["revelation_order"])
l=list(map(lambda y:y['name_simple'], x))
print(l)


Q no 3


print(reduce(lambda x, y:x+y["verses_count"], data['chapters'], 0))

usmantariq
Автор

1-b=[(i['name_simple'], i['revelation_order']) for i in data['chapters']]
print([j[0] for j in (sorted(b, key=lambda b:b[1]))])

2-print(list(map(lambda a:a['name_simple'], sorted(data2['chapters'], key= lambda b:b['revelation_order']))))

3-print(reduce(lambda x, y:x+y['verses_count'], data['chapters'], 0))

SafiUllah-kgku
Автор

Ans: 1

fil=filter(lambda a:a['category']=='alkali metal', data['elements'])
print(list(map(lambda b:b['symbol'], f)))


Ans: 2

sor=sorted(data['chapters'], key=lambda a:a['revelation_order'])
print(list(map(lambda b:b['name_simple'], s)))

Ans: 3

print(reduce(lambda a, b:a+b['verses_count'], data['chapters'], 0))

abdurrehmansarwar
Автор

Q1
x=[(i['name_simple'], i['revelation_order']) for i in data['chapters']]
print([j[0] for j in (sorted(x, key=lambda x:x[1]))])
Q2
from functools import reduce
print(reduce(lambda x, y: x + y["verses_count"], data['chapters'], 0))

maleehasyed
Автор

Q-1
x=[(i['name_simple'], i['revelation_order']) for i in data['chapters']]
print([j[0] for j in (sorted(x, key=lambda x:x[1]))])
Q-2
from functools import reduce
print(reduce(lambda x, y: x + y["verses_count"], data['chapters'], 0))

AsadAli-owie
Автор

# Review Question_01
x=filter(lambda m:m['ctgry']=='alkalis', data['element'])
print(list(map(lambda n:n['symbol'], x)))
# Review Question_02
x=sorted(data['chap'], key=lambda a:a['order'])
print(list(map(lambda b:b['name_simple'], x)))
# Review Question_03
print(reduce(lambda x, y:x+y['verses_count'], data['chap'], 0)

AbdullahKhan-xwqj
Автор

#Review Que 1:
x=[(i['name_simple'], i['revelation_order']) for i in data['chapters']]
print([j[0] for j in (sorted(x, key=lambda x:x[1]))])

#Review Que 2:
from functools import reduce
print(reduce(lambda x, y: x + y["verses_count"], data['chapters'], 0))

ahmadlatif
Автор

#Review Question-1#

l=[i["symbol"] for i in data['elements'] if i["category"]=="alkali metal"]
print(l)


#Review Question-2#


x=sorted(data["chapters"], key=lambda a:a["revelation_order"])
l=list(map(lambda y:y['name_simple'], x))
print(l)


#Review Question-3#


print(reduce(lambda x, y:x+y["verses_count"], data['chapters'], 0))

shaheerahmadkhan
Автор

#1
a=[i["symbol"] for i in data['elements'] if i["category"]=="alkali metal"]
print(a)

#2
b=sorted(data["chapters"], key=lambda a:a["revelation_order"])
a=list(map(lambda y:y['name_simple'], b))
print(a)

#3
print(reduce(lambda b, y:b+y["verses_count"], data['chapters'], 0))

dawoodimtiaz
Автор

Q-1
y=[i['name'] for i in data['elements'] if i['shells'][-1]==1 and i["category"]=="alkali metal"]
print(y)
Q-2
x=[(i['name_simple'], i['revelation_order']) for i in data['chapters']]
print([j[0] for j in (sorted(x, key=lambda x:x[1]))])
Q-3
from functools import reduce
print(reduce(lambda x, y: x + y["verses_count"], data['chapters'], 0))
#0 is initializer to keep x as an int and y['verses_count'] as dict

AliHamza-zwvt
Автор

REVIEW#1

l=[j["symbol"] for j in data['elements'] if j["category"]=="alkali metal"]
print(l)


REVIEW#2


x=sorted(data["chapters"], key=lambda b:b["revelation_order"])
l=list(map(lambda y:y['name_simple'], x))
print(l)


REVIEW#3


print(reduce(lambda x, y:x+y["verses_count"], data['chapters'], 0))

talhakamboh
Автор

## Review_Question_1 ##
f=filter(lambda a:a['category']=='alkali metal', data['elements'])
print(list(map(lambda a1:a1['symbol'], f)))

## Review_Question_2 ##
s=sorted(data['chapters'], key=lambda s1:s1['revelation_order'])
print(list(map(lambda s1: s1['name_simple'], s)))

## Review_Question_3 ##
from functools import reduce
v=reduce(lambda r1, r2:r1+r2['verses_count'], data['chapters'], 0)
print(v)

habibaasif
Автор

#Review_Question_1:
a=[i["symbol"] for i in data['elements'] if i["category"]=="alkali metal"]
print(a)

#Review_Question_2:
b=sorted(data["chapters"], key=lambda a:a["revelation_order"])
a=list(map(lambda y:y['name_simple'], b))
print(a)

#Review_Question_3:
print(reduce(lambda b, y:b+y["verses_count"], data['chapters'], 0))

abdul-hadi
Автор

1-
print([e['symbol'] for e in data['elements'] if(e["category"]=="alkali metal" and e['shells'][-1]==1)])

2-
s=sorted(data["chapters"], key=lambda a:a["revelation_order"])
print(list(map(lambda y:y['name_simple'], s)))

3-
print(reduce(lambda b, y:b+y["verses_count"], data['chapters'], 0))

huzaifasarwar
Автор

#REVIEW QUESTION - 1
print(list(map(lambda s:s['symbol'], filter(lambda f: and f['phase']!='Gas', data1['elements']))))



#REVIEW QUESTION - 2
print(list(map(lambda v:v['name_simple'], sorted(data2['chapters'], key= lambda s:s['revelation_order']))))



#REVIEW QUESTION - 3
print(functools.reduce(lambda a, b:a+b['verses_count'], data2['chapters'], 0))

amaanmajid
join shbcf.ru