Commit 7a3bc118 authored by Danijel Schorlemmer's avatar Danijel Schorlemmer
Browse files

Implemented the import of dwelling floorspace and sizes

parent 407eb9f7
Pipeline #21773 passed with stage
in 1 minute and 33 seconds
......@@ -364,13 +364,13 @@ class JapanDatabase(SpatialiteDatabase):
self.cursor.execute(sql_statement)
def insert_dwelling_floorspace(
self,
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
floorspace,
self,
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
floorspace,
):
"""
Inserts a full dataset to the DwellingFloorspace table.
......@@ -404,14 +404,14 @@ class JapanDatabase(SpatialiteDatabase):
self.cursor.execute(sql_statement)
def insert_dwelling_size_number(
self,
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
dwelling_size_type_id,
number_dwelling,
self,
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
dwelling_size_type_id,
number_dwelling,
):
"""
Inserts a full dataset to the DwellingSizeNumber table.
......@@ -573,7 +573,11 @@ class JapanDatabase(SpatialiteDatabase):
logger.info("Districts and boundaries added")
def import_exposure_data(
self, dwelling_numbers_filepath, building_numbers_filepath, household_numbers_filepath, dwelling_sizes_filepath
self,
dwelling_numbers_filepath,
building_numbers_filepath,
household_numbers_filepath,
dwelling_sizes_filepath,
):
"""
Imports all exposure data from the Excel files provided by E-Stat, Japan. The following
......@@ -773,7 +777,7 @@ class JapanDatabase(SpatialiteDatabase):
dwelling_sizes_input = pandas.read_excel(
dwelling_sizes_filepath,
header=10,
usecols=[4, 5, 7, 9, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21]
usecols=[4, 5, 7, 9, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21],
)
for index, row in dwelling_sizes_input.iterrows():
admin_id = int((row["Area classification"].split("_"))[0])
......@@ -804,12 +808,12 @@ class JapanDatabase(SpatialiteDatabase):
# Prepare and insert the data to the DwellingFloorspace table
floorspace = float(str(row[13]).replace("-", "0"))
self.insert_dwelling_floorspace(
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
floorspace,
district_id,
building_type_id,
dwelling_type_id,
tenure_type_id,
construction_material_id,
floorspace,
)
logger.debug(
"Floorspace for district %s, type %s, %s, %s, %s added"
......
......@@ -43,7 +43,9 @@ def main():
exit()
db.create_tables()
db.read_districts_and_boundaries("data/estat_bound_municipal.gpkg")
db.import_exposure_data("data/e008_3e.xlsx", "data/e039_3e.xlsx", "data/e011_2e.xlsx", "data/e014e.xlsx")
db.import_exposure_data(
"data/e008_3e.xlsx", "data/e039_3e.xlsx", "data/e011_2e.xlsx", "data/e014e.xlsx"
)
# Leave the program
sys.exit()
......
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