From 6eb870747da9a820d763cb9004767ef0d2b962aa Mon Sep 17 00:00:00 2001 From: tomasz t Date: Sun, 27 Mar 2022 01:44:55 +0100 Subject: [PATCH] removed download of custom_layer data --- download_data.py | 42 ------------------------------------------ requirements.txt | 1 - 2 files changed, 43 deletions(-) diff --git a/download_data.py b/download_data.py index 03d2a81..7673ad7 100644 --- a/download_data.py +++ b/download_data.py @@ -9,7 +9,6 @@ from datetime import datetime, timezone from pathlib import Path import pyexcel_ods3 -import gspread logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") logger = logging.getLogger(__file__) @@ -219,46 +218,6 @@ def main_overpass( save_json(file_path=json_metadata_file_path, data=json_metadata) -def main_google_sheets(output_dir: Path, config_files_dir: Path) -> None: - sa_credentials_json_path = ( - config_files_dir.joinpath("sa-credentials.json").resolve().as_posix() - ) - config_path = config_files_dir.joinpath("gsheetsurl").resolve().as_posix() - - custom_layer_file_path = output_dir.joinpath("custom_layer.geojson") - geojson = deepcopy(geojson_template) - - try: - with open(config_path, "r").read() as gsheets_url: - logger.info("Reading Google Sheets credentials.") - gc = gspread.service_account(filename=sa_credentials_json_path) - logger.info("Opening Google Sheets url.") - gsheet = gc.open_by_url(gsheets_url) - data = gsheet.worksheet("dane_raw").get_all_records() - logger.info( - f"Reading rows from Google Sheets. Rows to process: {len(data)}." - ) - counter = 0 - for row in data: - if ( - all([row["latitude"], row["longitude"]]) - and row.get("import", "UNKNOWN") == "FALSE" - ): - geojson["features"].append( - geojson_point_feature( - lat=row["latitude"], - lon=row["longitude"], - properties={"type": row.get("typ")}, - ) - ) - counter += 1 - logger.info(f"{counter} features to export.") - if len(geojson["features"]) > 0: - save_json(file_path=custom_layer_file_path.as_posix(), data=geojson) - except FileNotFoundError: - logger.error(f"Config file not found. [config_path={config_path}]") - - if __name__ == "__main__": this_files_dir = Path(__file__).parent.resolve() @@ -275,4 +234,3 @@ if __name__ == "__main__": prefixes=prefix_to_add, col_name_map=tag_name_mapping, ) - main_google_sheets(output_dir=arg1, config_files_dir=arg2) diff --git a/requirements.txt b/requirements.txt index 79ff74f..2f6a484 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ requests pyexcel-ods3==0.6.0 -gspread==5.1.1