Commit 14a13f4b authored by Eric Duminil's avatar Eric Duminil
Browse files

Export to CSV automatically

parent d37cd341
......@@ -25,6 +25,7 @@ import geopandas as gpd
from tree import Forest
from import_existing_trees import get_existing_forest
from export_OSM_roads_to_csv import write_roads_to_csv
################################################################################
# USER PARAMETERS #
......@@ -133,6 +134,7 @@ def get_osm_roads(bounds: Bounds):
print("Caching data...")
with open(cache_file, 'wb') as cache:
pickle.dump(ways, cache)
write_roads_to_csv(cache_file)
return ways
......
......@@ -39,7 +39,7 @@ def create_table(ways):
return df
for cache_path in Path('cache').glob('*.pickle'):
def write_roads_to_csv(cache_path):
print(f"Parsing {cache_path}")
df = create_table(load_cache(cache_path))
csv_output = Path('output') / f'OSM_infos_{cache_path.stem}.csv'
......@@ -49,3 +49,12 @@ for cache_path in Path('cache').glob('*.pickle'):
decimal=',',
encoding='utf-8-sig'
)
def main():
for cache_path in Path('cache').glob('*.pickle'):
write_roads_to_csv(cache_path)
if __name__ == "__main__":
main()
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