Commit 307f264e authored by Simantini Shinde's avatar Simantini Shinde
Browse files

Exported BuildingAsset table to CSV

parent 04f3df3e
Pipeline #40627 passed with stage
in 1 minute and 47 seconds
......@@ -2051,3 +2051,30 @@ class JapanDatabase(SpatialiteDatabase):
self.cursor.execute(sql_statement)
self.connection.commit()
logger.info("Building attributes and their values added into the BuildingAsset table")
def export_to_csv(self, csv_filepath):
"""
Exports the BuildingAsset table into CSV format.
"""
# Export the BuildingAsset table into a CSV file
csv_writer = csv.writer(open(csv_filepath, "w"))
header = [
"id",
"admin_id",
"admin_name",
"occupancy",
"taxonomy",
"number",
"structural",
"night",
"geom",
]
csv_writer.writerow(header)
sql_statement = "SELECT id, admin_id, admin_name, occupancy, taxonomy, number, "
sql_statement += "structural, night, AsText(geom) "
sql_statement += "FROM BuildingAsset"
self.cursor.execute(sql_statement)
rows = self.cursor.fetchall()
csv_writer.writerows(rows)
logger.info("BuildingAsset table exported to CSV")
......@@ -52,6 +52,7 @@ def main():
)
db.import_gem_building_class_mapping("mapping_files/GEM_Tax_Building_class.xlsx")
db.assign_building_assets()
db.export_to_csv("output.csv")
# Leave the program
sys.exit()
......
Supports Markdown
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