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

Web で閲覧できる次の表を作成します。
>[福島県の新型コロナウイルス感染症患者の発生状況](https://ekzemplaro.org/corona/fukushima_patient/)
![fukushima_apr20.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/179446/d67a2ca2-325f-2657-81cf-65c7f7403ea7.png)

データのソースは福島県のサイトにある csv です。
>[/covid19/patients](http://www.pref.fukushima.lg.jp/w4/covid19/patients/)

csv の取得

```bash
URL="http://www.pref.fukushima.lg.jp/w4/covid19/patients"
#
wget $URL"/070009_fukushima_covid19_patients_200420.csv"
```

JSON への変換

```bash
iconv -f sjis -t UTF-8 070009_fukushima_covid19_patients_200420.csv > fukushima_200420.csv
#
./fukushima_corona.py fukushima_200420.csv data_fukushima.json
```

```py:fukushima_corona.py
#! /usr/bin/python
# -*- coding: utf-8 -*-
#
#	fukushima_corona.py
#
#						Apr/19/2020
#
import	sys
import	string
import	json
import	csv
#
# ------------------------------------------------------------------
def parse_proc(dict_aa,row):
	ix = int(row[0])
	key = "s%03d" % ix
	unit_aa = {}
	unit_aa['date'] = row[4]
	unit_aa['age'] = row[7]
	unit_aa['sex'] = row[8]
	unit_aa['place'] = row[6]
#	unit_aa['status'] = row[5]
	dict_aa[key] = unit_aa
#
	return	dict_aa
# ------------------------------------------------------------------
sys.stderr.write ("*** 開始 ***\n")
file_csv = sys.argv[1]
file_json = sys.argv[2]
sys.stderr.write(file_csv + "\n")
sys.stderr.write(file_json + "\n")
#
fp = open(file_csv, 'r')
reader = csv.reader(fp)
dict_aa = {}
for row in reader:
	if row[0] != "No":
		dict_aa = parse_proc(dict_aa,row)
#
fp.close()

#
dict_bb = {}
for key in sorted(dict_aa.keys(), reverse=True):
	dict_bb[key] = dict_aa[key]
#
json_str = json.dumps(dict_bb)
#
fp_out = open(file_json,mode='w',encoding='utf-8')
fp_out.write(json_str)
fp_out.close()
#
sys.stderr.write ("*** 終了 ***\n")
# ------------------------------------------------------------------
```

ホームページ

```html:fukushima_patient.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />
<script src="/js/jquery-3.4.1.min.js"></script>
<script src="fukushima_patient.js"></script>
<link rel="stylesheet" href="fukushima_patient.css">
<title>福島県の新型コロナウイルス感染症患者の発生状況</title>
</head>
<body>
<blockquote>
<h2>福島県の新型コロナウイルス感染症患者の発生状況</h2><p />
	<blockquote>
	(4月19日 時点)<p />
	</blockquote>
</blockquote>
	<blockquote>
	<div class="contents"></div>
	</blockquote>
</blockquote>
<hr />
データソース
	<blockquote>
	<a href="http://www.pref.fukushima.lg.jp/w4/covid19/patients/"  target="_blank">/covid19/patients</a><p />
	</blockquote>

<a href="../">Return</a><p />
Apr/19/2020 AM 07:00<p />
</body>
</html>
```

```css:fukushima_patient.css
/* -------------------------------------------------------------- */
/*

	fukushima_patient.css

						Apr/20/2020

*/
/* -------------------------------------------------------------- */
table.main,td,th {
table-layout:fixed;
border:1.5px #7e7e7e solid;
border-collapse: collapse;
height: 16px;
}

th {
	background: #c6c6c6;
}


table.tag {
border:0.5px green solid;
}

tr.cyan {
	background-color: #c7d7c7;
}

.red {color:#ff0000;}

/* -------------------------------------------------------------- */
```

```js:fukushima_patient.js
// -----------------------------------------------------------------------
//	fukushima_patient.js
//
//					Apr/19/2020
//
// -----------------------------------------------------------------------
jQuery (function ()
{
	jQuery("#outarea_aa").text ("*** fukushima_patient *** start ***")

	const file_in = "./data_fukushima.json"

	jQuery.getJSON (file_in,function (data_aa)
		{
		var str_out = ""
		str_out += "<table>"
		str_out += "<tr>"
		str_out += "<th>No</th>"
		str_out += "<th>判明日</th>"
		str_out += "<th>年代</th>"
		str_out += "<th>性別</th>"
		str_out += "<th>居住地</th>"
		str_out += "<th>退院済</th>"
		str_out += "</tr>"

		for (var key in data_aa)
			{
			const unit_aa = data_aa[key]
			str_out += "<tr>"
			str_out += "<td>" + key + "</td>"
			str_out += "<td>" + unit_aa.date + "</td>"
			str_out += "<td>" + unit_aa.age + "</td>"
			str_out += "<td>" + unit_aa.sex + "</td>"
			str_out += "<td>" + unit_aa.place + "</td>"
//			str_out += "<td>" + unit_aa.status + "</td>"
			str_out += "<td>---</td>"
			str_out += "</tr>"

			}

		str_out += "</table>"

		jQuery(".contents").html (str_out)
		})

	jQuery("#outarea_hh").text ("*** fukushima_patient *** end ***")

})

// -----------------------------------------------------------------------
```