Skip to content

Instantly share code, notes, and snippets.

@blogcacanid
Last active April 18, 2020 06:21
Show Gist options
  • Save blogcacanid/c64eff7675401f47d83b2a99735a35da to your computer and use it in GitHub Desktop.
Save blogcacanid/c64eff7675401f47d83b2a99735a35da to your computer and use it in GitHub Desktop.
covid19.py Sistem Informasi Covid-19 Python Detail Indonesia
def detail_indonesia():
print('*** DETAIL COVID-19 INDONESIA')
url = "https://api.kawalcorona.com/indonesia/provinsi/"
data = requests.get(url).text
obj = json.loads(data)
pTable = PrettyTable()
pTable.field_names = ['No.', 'Propinsi', 'Positif', 'Sembuh', 'Meninggal']
# Mengatur posisi text r=right, l=left, c=center
pTable.align['No'] = 'r'
pTable.align['Propinsi'] = 'l'
pTable.align['Positif'] = 'r'
pTable.align['Sembuh'] = 'r'
pTable.align['Meninggal'] = 'r'
no = 0
for i in obj:
no += 1
row_details = [no, i['attributes']['Provinsi'], i['attributes']['Kasus_Posi'], i['attributes']['Kasus_Semb'], i['attributes']['Kasus_Meni']]
pTable.add_row(row_details)
print(pTable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment