0
0

More than 3 years have passed since last update.

茨城県の新型コロナウイルス感染症患者の発生状況の表を作成 (その2)

Posted at

次のページのデータソースを変更しました。
茨城県の新型コロナウイルス感染症患者の発生状況の表を作成

データソース

新型コロナウイルス感染症
対策サイト(非公式)

JSON の取得

wget https://raw.githubusercontent.com/a01sa01to/covid19-ibaraki/development/data/data.json

データの変換

jq .patients data.json > patients.json
./ibaraki_convert.py patients.json data_ibaraki.json
ibaraki_convert.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
#   ibaraki_convert.py
#
#                   Apr/20/2020
#
# ------------------------------------------------------------------
import sys
import json
#
sys.path.append('/var/www/data_base/common/python_common')
from file_io import file_to_str_proc
from file_io import file_write_proc
# ------------------------------------------------------------------
file_in = sys.argv[1]
file_out = sys.argv[2]
#
sys.stderr.write("*** start ***\n")
#
json_str = file_to_str_proc(file_in)
array_aa = json.loads(json_str)
#
dict_aa = {}
count = 1
for unit_aa in array_aa['data']:
    unit_bb = {}
    key = "i%03d" % int(unit_aa['num'])
    unit_bb["place"] = unit_aa["居住地"]
    if "年代" in unit_aa:
        unit_bb["age"] = unit_aa["年代"]
    else:
        unit_bb["age"] = ""
    unit_bb["sex"] = unit_aa["性別"]
    unit_bb["date"] = unit_aa["date"]
    unit_bb["status"] = unit_aa["退院"]
    dict_aa[key] = unit_bb
    count += 1
#
dict_bb = {}
for key in sorted(dict_aa.keys(), reverse=True):
    dict_bb[key] = dict_aa[key]
#
out_str = json.dumps(dict_bb)
file_write_proc(file_out,out_str)
#
sys.stderr.write("*** end ***\n")
# ------------------------------------------------------------------

ホームページ
こちらと同じです。

茨城県の新型コロナウイルス感染症患者の発生状況の表を作成

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0