From 380dd22b37d2bd377276c8325497e519e18ec84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Fri, 13 Mar 2020 09:24:56 +0100 Subject: [PATCH] Improve to_csv message --- .../data/observatory/catalog/entity.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cartoframes/data/observatory/catalog/entity.py b/cartoframes/data/observatory/catalog/entity.py index 57b0d05d1..ce92ce067 100644 --- a/cartoframes/data/observatory/catalog/entity.py +++ b/cartoframes/data/observatory/catalog/entity.py @@ -9,6 +9,19 @@ _PLATFORM_BQ = 'bq' +_DATASET_READ_MSG = '''To load it as a DataFrame you can do: + + df = pandas.read_csv('{}') +''' + +_GEOGRAPHY_READ_MSG = '''To load it as a GeoDataFrame you can do: + + from cartoframes.utils import decode_geometry + + df = pandas.read_csv('{}') + gdf = GeoDataFrame(df, geometry=decode_geometry(df['geom'])) +''' + class CatalogEntity(ABC): """This is an internal class the rest of the classes related to the catalog discovery extend. @@ -133,8 +146,11 @@ def _download(self, credentials, file_path=None, limit=None): if file_path: bq_client.download_to_file(job, file_path, column_names=column_names) - log.info('Data saved: {}.'.format(file_path)) - log.info("To read it you can do: `pandas.read_csv('{}')`.".format(file_path)) + log.info('Data saved: {}'.format(file_path)) + if self.__class__.__name__ == 'Dataset': + log.info(_DATASET_READ_MSG.format(file_path)) + elif self.__class__.__name__ == 'Geography': + log.info(_GEOGRAPHY_READ_MSG.format(file_path)) else: return bq_client.download_to_dataframe(job)