-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download #1050
Merged
Merged
Download #1050
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
e577715
first PoC
simon-contreras-deel 22f0e9f
download by query
simon-contreras-deel e6e4a83
download as a dataframe
simon-contreras-deel 5e118c0
storage api version
simon-contreras-deel bc142c4
download file
simon-contreras-deel afa0a43
download default file
simon-contreras-deel 0885cc6
using csv module
simon-contreras-deel c87d8f8
progress_bar
simon-contreras-deel 6aab3bc
fail is file exists
simon-contreras-deel cd4b85b
fail if exists param
simon-contreras-deel 52f6eed
rmoving dataframe and storar api methods
simon-contreras-deel a99ab80
using self.query
simon-contreras-deel 14a6b21
testing download
simon-contreras-deel 1b5b274
updating notebook
simon-contreras-deel 7fbcc00
download_to_file
simon-contreras-deel 5a9385b
Merge branch 'develop' into feature/do-bq-download
simon-contreras-deel 22052b1
Merge branch 'develop' into feature/do-bq-download
simon-contreras-deel 347a770
progress bar param
simon-contreras-deel 0bb9c35
return path instead of warn
simon-contreras-deel 3f7f575
dataset download
simon-contreras-deel 4d7e705
gepgraphy download
simon-contreras-deel cc7f513
updating notebook
simon-contreras-deel 25f3c5d
basic dataset test
simon-contreras-deel 8b60a43
basic geography test
simon-contreras-deel 5be6f74
detail in test fixtures
simon-contreras-deel 4832fa2
add column names in csv file
simon-contreras-deel 09d64f4
ensuring csv header test
simon-contreras-deel de769d6
updating notebook
simon-contreras-deel 5106dd1
refactoring download code into entity
simon-contreras-deel a561a8e
download docs
simon-contreras-deel a6bdbf0
typo
simon-contreras-deel 2dbe2b3
Improve message
simon-contreras-deel 01f1907
remove BQ client from notebook
simon-contreras-deel b8562bf
get_do_dataset method
simon-contreras-deel 0d82706
get_do_dataset def and avoid warnings from carto-python
simon-contreras-deel c43c434
unify mocks
simon-contreras-deel 1256e45
remove ds references
simon-contreras-deel daeb73c
changelog
simon-contreras-deel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from cartoframes.auth import Credentials\n", | ||
"credentials = Credentials.from_file()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Catalog Dataset" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from cartoframes.data.observatory.catalog import Catalog\n", | ||
"dataset = Catalog().categories.get('financial').datasets.get('{dataset_id}')\n", | ||
"dataset.to_series()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dataset.download(credentials)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Catalog Geography " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from cartoframes.data.observatory.geography import Geography\n", | ||
"geography = Geography.get(dataset.geography)\n", | ||
"geography.to_series()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"file_path = geography.download(credentials)\n", | ||
"file_path" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Upload downloaded csv file to CARTO " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"\n", | ||
"df = pd.read_csv(file_path)\n", | ||
"df.head()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from cartoframes.data import Dataset\n", | ||
"\n", | ||
"Dataset(df).upload(table_name='test_do_geography', credentials=credentials, if_exists='replace')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Visualize it" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from cartoframes.viz import Map, Layer\n", | ||
"Map(Layer('test_do_geography', credentials=credentials))" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will use this for both downloading a plain dataset or a geographies dataset. I'd like to be sure of the geometry format downloaded and written in the CSV.
Could we add a test to make sure that we can read/upload to CARTO the geometry in the downloaded CSV file for a geography table? (or any other type of test that you think it might be interesting for this case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The geometry is saved as WKT as string in the file
We could use a
carto-do-public-data
for that, but I would not really like to make a tests end to end against big query and carto.(still thinking about it)