-
Notifications
You must be signed in to change notification settings - Fork 0
/
tokyo.py
22 lines (15 loc) · 883 Bytes
/
tokyo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
print("Current working directory at: " + os.getcwd())
print("Fetching raw hospitalization data for Tokyo from directory: ")
print("data/raw/tokyo-hospitalizations-from-html-table.txt")
tokyo_hos_data = open("data/raw/tokyo-hospitalizations-from-html-table.txt", "r").readlines()
formatted_tokyo_hos_data = open("studies/formatted/tokyo-hospitalizations.csv", "w+")
reversed_data_seq = []
for line in range(3, len(tokyo_hos_data)):
# ignore all HTML code blocks unless on a line with a multiple of 4 (indexing starts at 0)
if (line - 3) % 4 == 0:
reversed_data_seq.append(tokyo_hos_data[line])
reversed_data_seq = reversed(reversed_data_seq)
formatted_tokyo_hos_data.writelines(reversed_data_seq)
print("Raw hospitalization data has been formatted.")
print("The formatted hospitalization data can be found at `data/formatted/tokyo-hospitalizations`")