Commit 4b52c849 authored by 齐昊宇's avatar 齐昊宇

表5数据完成

parent bf6b0f0f
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
......@@ -76,6 +76,38 @@ tableInfos = {
'year_report_id': 'int',
'month': 'string',
'state': 'string'
},
"oie_year_report_unreported": {
'disease': 'string',
'disease_id': 'int',
'country_code': 'string',
'year': 'int',
'type': 'string',
'animal': 'string',
'year_report_id': 'int',
'id': 'int'
},
"oie_year_report_summary_non": {
"non_oie_listed_disease": "string",
"occurrence": "string",
"serotype": "string",
"new_outbreaks": 'string',
"total_outbreaks": "string",
"species": "string",
"control_measures": "string",
"official_vaccination": "string",
"measuring_units": "string",
"susceptible": "string",
"cases": "string",
"deaths": 'string',
"killed_and_disposed_of": "string",
"slaughtered": "string",
"vaccination_in_response_to_the_outbreak": "string",
"country_code": "string",
"year": "int",
"type": "string",
"year_report_id": "int",
"id": "int"
}
}
......
......@@ -6,7 +6,7 @@ class Database():
html = ''
res = ''
count = 10
start = 76
start = 1
year = ''
country = ''
type = ''
......@@ -54,6 +54,23 @@ class Database():
'Slaughtered': "slaughtered",
'Vaccination in response to the outbreak(s)': 'vaccination_in_response_to_the_outbreak'
} # 3
summary_non_col_dict = {
"NON OIE-Listed disease": "non_oie_listed_disease",
"occurrence": "occurrence",
"Serotype(s)": "serotype",
"New outbreaks": "new_outbreaks",
"Total outbreaks": "total_outbreaks",
"Species": "species",
"Control Measures": "control_measures",
"Official vaccination": "official_vaccination",
"Measuring units": "measuring_units",
"Susceptible": "susceptible",
"Cases": "cases",
"Deaths": 'deaths',
"Killed and disposed of": "killed_and_disposed_of",
"Slaughtered": "slaughtered",
"Vaccination in response to the outbreak(s)": "vaccination_in_response_to_the_outbreak"
}
def __init__(self):
self.get_disease_list()
......@@ -93,13 +110,16 @@ class Database():
# print(table_2)
elif i[j]['no'] == 3: # detail
table_3 = self.handle_a_table_3(i[j]['tables'])
self.insert_into_3(table_3)
# self.insert_into_3(table_3)
# print(table_3)
elif i[j]['no'] == 4:
table_4 = self.handle_a_table_4(i[j]['tables'])
# self.insert_into_4(table_4)
# print(table_4)
elif i[j]['no'] == 5:
table_5 = self.handle_a_table_5(i[j])
if table_5:
self.insert_into_5(table_5)
# print(table_5)
elif i[j]['no'] == 6:
table_6 = self.handle_a_table_6(i[j])
......@@ -146,10 +166,6 @@ class Database():
ths.append(self.summary_col_dict[i])
for i in table['td']:
tmp = {}
tmp['year_report_id'] = self.id
tmp['country_code'] = self.country
tmp['year'] = self.year
tmp['type'] = self.type
disease = i[0]
disease = disease.replace(' (Domestic and Wild)', '')
disease = disease.replace(' (Domestic)', '')
......@@ -187,11 +203,7 @@ class Database():
tmp_1 = tmp_1.replace(' (Wild)', '')
tmp[ths[td_no]] = tmp_1
tmp['animal'] = animal
tmp['country_code'] = self.country
tmp['year'] = self.year
tmp['type'] = self.type
tmp['disease_id'] = self.get_disease_standard_id(disease)
tmp['year_report_id'] = self.id
self.insert_to_table(tmp, 'oie_year_report_never_report', '表2数据已存在')
def handle_a_table_3(self, table):
......@@ -218,7 +230,7 @@ class Database():
tmp['year'] = self.year
tmp['year_report_id'] = self.id
tmp['disease'] = disease_name
tmp['type'] = a_table['type']
tmp['animal_type'] = a_table['type']
th = a_table['th']
for a_th in th:
ths.append(self.detail_col_dict[a_th])
......@@ -241,11 +253,38 @@ class Database():
ok_table.append({key: diseases})
return ok_table
def insert_into_4(self, table):
for a_table in table:
key = self.dict_key(a_table)
value = a_table[key]
for a_disease in value:
disease_id = self.get_disease_standard_id(self.get_standard_disease_name(a_disease))
tmp = {
"disease_id": disease_id,
"disease": a_disease,
"animal": key
}
self.insert_to_table(tmp, "oie_year_report_unreported", "表4已存在")
def handle_a_table_5(self, table):
auto = [0, 1, 2]
if table['type'] == 'table':
return self.ana_table_to_ok(table, auto)
def insert_into_5(self, table):
th = table['th']
td = table['td']
ths = []
for i in th:
ths.append(self.summary_non_col_dict[i])
for a_tr in td:
tmp = {}
for key, val in enumerate(a_tr):
tmp[ths[key]] = val
self.insert_to_table(tmp, "oie_year_report_summary_non", '表5数据已存在')
def handle_a_table_6(self, table):
if table['tables']:
ok_table = []
......@@ -253,7 +292,6 @@ class Database():
for type, item in i.items():
a_ok_table = self.ana_table_to_ok(item)
ok_table.append({type: a_ok_table})
print(ok_table)
def handle_a_table_7(self, table):
auto = [0]
......@@ -282,15 +320,12 @@ class Database():
res = self.ana_table_to_ok(table, auto)
def handle_a_table_11(self, table):
print(table)
tables = []
print(table['tables'])
if len(table['tables']) != 0:
for i in table['tables']:
for key, item in i.items():
table = self.ana_table_to_ok(item)
tables.append({key: table})
print(tables)
def handle_a_table_12(self, table):
res = self.ana_table_to_ok(table)
......@@ -349,6 +384,10 @@ class Database():
return False
def insert_to_table(self, data, table_name, msg):
data['country_code'] = self.country
data['year'] = self.year
data['year_report_id'] = self.id
data['type'] = self.type
if self.is_exist(table_name, data):
print(msg + str(data))
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment