Skip to content

Commit

Permalink
Merge pull request #1589 from CartoDB/jarroyo/ch59309/read-csv-sugges…
Browse files Browse the repository at this point in the history
…tion

Improve to_csv message
  • Loading branch information
Jesus89 authored Mar 16, 2020
2 parents 77271cc + 380dd22 commit 01a3d4b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions cartoframes/data/observatory/catalog/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -135,8 +148,11 @@ def _download(self, credentials, file_path=None, limit=None, order_by=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)

Expand Down

0 comments on commit 01a3d4b

Please sign in to comment.