def convert2json(csvData, dtUpdated): try: listDate = csvData["公表_年月日"] listCity = csvData["市区町村名"] listResidence = csvData["患者_居住地"] listAge = csvData["患者_年代"] listSex = csvData["患者_性別"] listDischarge = None try: listDischarge = csvData["患者_退院済フラグ"] except Exception as e: # 浜松市 listDischarge = csvData["退院済フラグ"] dataList = [] for n in range(len(listDate)): Date = re.split('[年月日:;.,-/]', listDate[n]) for i in (1, 2): Date[i] = Date[i].zfill(2) day = Date[0] + "-" + Date[1] + "-" + Date[2] releaseday = "{0}T08:00:00.000Z".format(day) Residence = listResidence[n] if covid19_util.is_nan(Residence): Residence = "--" residence = listCity[n] + ' ' + Residence age = listAge[n] if covid19_util.is_nan(age): age = "不明" sex = listSex[n] if covid19_util.is_nan(sex): sex = "不明" discharge = int(listDischarge[n]) if covid19_util.is_nan(discharge): discharge = "不明" dataList.append({ "リリース日": releaseday, "居住地": residence, "年代": age, "性別": sex, "退院": discharge, "date": day }) return {"date": dtUpdated.strftime('%Y/%m/%d %H:%M'), "data": dataList} except Exception as e: logger.exception(e) return None
def convert2json(csvData, dtUpdated): try: listDate = csvData["受付_年月日"] listCnt = csvData["相談件数"] list = [] length = len(listDate) for n in range(length): Date = re.split('[年月日:;.,-/]', listDate[n]) for i in (1, 2): Date[i] = Date[i].zfill(2) day = Date[0] + "-" + Date[1] + "-" + Date[2] cnt = listCnt[n] if not covid19_util.is_nan(cnt): list.append({ '日付': "{0}T08:00:00.000Z".format(day), "小計": int(cnt) }) return {"date": dtUpdated.strftime('%Y/%m/%d %H:%M'), "data": list} except Exception as e: logger.exception(e) return None
def convert2json(csvData, dtUpdated): try: listDate = csvData["公表_年月日"] listPosi = csvData["陽性患者人数"] dataList = [] for n in range(len(listDate)): Date = re.split('[年月日:;.,-/]', listDate[n]) for i in (1, 2): Date[i] = Date[i].zfill(2) day = Date[0] + "-" + Date[1] + "-" + Date[2] releaseday = "{0}T08:00:00.000Z".format(day) posiCnt = listPosi[n] if covid19_util.is_nan(posiCnt): posiCnt = 0 dataList.append({"日付": releaseday, "小計": int(posiCnt)}) return {"date": dtUpdated.strftime('%Y/%m/%d %H:%M'), "data": dataList} except Exception as e: logger.exception(e) return None
def convert2json(csvData, dtUpdated): try: listDate = csvData["実施_年月日"] listCnt = csvData["検査実施_人数"] labels = [] dataList = [] length = len(listDate) for n in range(length): Date = re.split('[年月日:;.,-/]', listDate[n]) for i in (1, 2): Date[i] = Date[i].zfill(2) day = Date[0] + "-" + Date[1] + "-" + Date[2] cnt = listCnt[n] if covid19_util.is_nan(cnt): cnt = int(0) labels.append("{0}T08:00:00.000Z".format(day)) dataList.append(int(cnt)) datasets = [] datasets.append({"label": "PCR検査実施人数", "data": dataList}) return { "date": dtUpdated.strftime('%Y/%m/%d %H:%M'), "labels": labels, "datasets": datasets } except Exception as e: logger.exception(e) return None
def convert2json(csvData, dtUpdated): try: timeStart = time.perf_counter() #main_summary.pyの変数を流用 listStatus = csvData["患者_状態"] #症状別入院数カウントに利用 listDischa = None #入院数/退院数カウントに利用 try: listDischa = csvData["患者_退院済フラグ"] except Exception as e: # 浜松市 listDischa = csvData["退院済フラグ"] sumPosi = 0 #陽性患者数 sumHosp = 0 #入院中 sumMild = 0 #軽症・中軽症 + 無症状 sumServ = 0 #重症 sumDischa = 0 #退院 sumDeath = 0 #死亡 #陽性患者=リストの要素数 sumPosi = len(csvData) for n in range(len(csvData)): #入院中患者のカウント if covid19_util.is_nan(listDischa[n]): sumHosp = sumHosp elif listDischa[n] == 0: sumHosp += 1 #軽症・中等症者のカウント if covid19_util.is_nan(listStatus[n]): sumMild = sumMild elif (listStatus[n] == "軽症" or listStatus[n] == "中等症" or listStatus[n] == "無症状") and listDischa[n] == 0: sumMild += 1 #重症者のカウント if covid19_util.is_nan(listStatus[n]): sumServ = sumServ elif (listStatus[n] == "重症") and listDischa[n] == 0: sumServ += 1 #退院者カウント if covid19_util.is_nan(listDischa[n]): sumDischa = sumDischa elif listDischa[n] == 1: sumDischa += 1 #死亡 if covid19_util.is_nan(listStatus[n]): sumDeath = sumDeath elif listStatus[n] == "死亡": sumDeath += 1 timeCurr = time.perf_counter() logger.info("covid19_main_summary TIME = {0} sec".format( (timeCurr - timeStart))) return { "date": dtUpdated.strftime('%Y/%m/%d %H:%M'), "children": [{ "attr": "陽性患者数", "value": int(sumPosi), "children": [{ "attr": "入院中", "value": int(sumHosp), "children": [{ "attr": "軽症・中等症", "value": int(sumMild) }, { "attr": "重症", "value": int(sumServ) }] }, { "attr": "退院", "value": int(sumDischa) }, { "attr": "死亡", "value": int(sumDeath) }] }] } except Exception as e: logger.exception(e) return None
def convert2json(csvData, dtUpdated): try: listCnt = csvData["検査実施人数"] listPosi = csvData["陽性患者数"] listHosp = csvData["入院中"] listMild = csvData["軽症・中軽症"] listServ = csvData["重症"] listDischa = csvData["退院"] listDeath = csvData["死亡"] sumCnt = 0 sumPosi = 0 sumHosp = 0 sumMild = 0 sumServ = 0 sumDischa = 0 sumDeath = 0 for n in range(len(listCnt)): if covid19_util.is_nan(listCnt[n]): sumCnt = sumCnt else: sumCnt = sumCnt + listCnt[n] if covid19_util.is_nan(listPosi[n]): sumPosi = sumPosi else: sumPosi = sumPosi + listPosi[n] if covid19_util.is_nan(listHosp[n]): sumHosp = sumHosp else: sumHosp = sumHosp + listHosp[n] if covid19_util.is_nan(listMild[n]): sumMild = sumMild else: sumMild = sumMild + listMild[n] if covid19_util.is_nan(listServ[n]): sumServ = sumServ else: sumServ = sumServ + listServ[n] if covid19_util.is_nan(listDischa[n]): sumDischa = sumDischa else: sumDischa = sumDischa + listDischa[n] if covid19_util.is_nan(listDeath[n]): sumDeath = sumDeath else: sumDeath = sumDeath + listDeath[n] return { "date": dtUpdated.strftime('%Y/%m/%d %H:%M'), "attr": "検査実施人数", "value": int(sumCnt), "children": [{ "attr": "陽性患者数", "value": int(sumPosi), "children": [{ "attr": "入院中", "value": int(sumHosp), "children": [{ "attr": "軽症・中等症", "value": int(sumMild) }, { "attr": "重症", "value": int(sumServ) }] }, { "attr": "退院", "value": int(sumDischa) }, { "attr": "死亡", "value": int(sumDeath) }] }] } except Exception as e: logger.exception(e) return None