Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit dfc54f4

Browse files
authored
Merge pull request #61 from rht/master
csv_format: Use pathlib.Path for output_dir
2 parents ac6a3de + f6bcd43 commit dfc54f4

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

firststreet/api/csv_format.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import datetime
66
import logging
77
import os
8+
import pathlib
89
import shapely.geometry
910

1011
# External Imports
@@ -33,7 +34,8 @@ def to_csv(data, product, product_subtype, location_type=None, output_dir=None):
3334
file_name = "_".join([date, product, product_subtype]) + ".csv"
3435

3536
if not output_dir:
36-
output_dir = os.getcwd() + "/output_data"
37+
output_dir = pathlib.Path(os.getcwd()) / "output_data"
38+
output_dir = pathlib.Path(output_dir)
3739

3840
if not os.path.exists(output_dir):
3941
os.makedirs(output_dir)
@@ -194,8 +196,8 @@ def to_csv(data, product, product_subtype, location_type=None, output_dir=None):
194196
df = df.drop(columns=['error'])
195197

196198
df = df.fillna(pd.NA).astype(str)
197-
df.to_csv(output_dir + '/' + file_name, index=False)
198-
logging.info("CSV generated to '{}'.".format(output_dir + '/' + file_name))
199+
df.to_csv(output_dir / file_name, index=False)
200+
logging.info("CSV generated to '{}'.".format(output_dir / file_name))
199201

200202

201203
def get_geom_center(geom):

0 commit comments

Comments
 (0)