# !/root/venv/bin/python -m pip install --upgrade pip
# !pip install urllib3
# Load Library
import json
import pandas as pd
# JSON file
f = open ('/work/Dataset/data.json', "r")
# Reading from file
data = json.loads(f.read())
# Iterating through the json
# list
data['data']['dosen']
# Closing file
f.close
# convert json to dataframe
df = pd.DataFrame(data['data']['dosen'])
df.head()
df.isnull().any()
df.isnull().sum()
# Helper Dictionary
dictionary = {
'name' : ['Ike','Togu','Tiurma','Monalisa','Goklas'],
'nidn' : ['','','','','','']
}
for value in dictionary['name']:
print(value)
print(dictionary.items())
print(dictionary['name'][0])
# Declare function
def checkEmail1(pegawaiId):
print(df['pegawaiId'] == pegawaiId)
def checkEmail2(name='',nidn=''):
if(len(name) + len(nidn) >= 3):
print(pd.DataFrame(df.loc[(df['nama'].str.contains(name)) & (df['nidn'].str.contains(nidn)),['nama','email'] ]))
def checkEmailWithDict(data):
for i in range(len(data['name'])):
if(len(data['name'][i]) + len(data['nidn'][i]) >= 3):
print(pd.DataFrame(df.loc[(df['nama'].str.contains(data['name'][i])) & (df['nidn'].str.contains(data['nidn'][i])),['nama','email'] ]))
# Filter
df_email = df[['nama','email']]
df_email.head()
# Export
# df_email.to_csv("/work/Dataset/dosenMail.csv")
dictionary = {
'name' : ['Ike','Togu','Tiurma','Monalisa','Goklas'],
'nidn' : ['','','','','','']
}
checkEmailWithDict(dictionary)