This file contains hidden or 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
""" | |
Example script for loading data from a .csv file into your Mozart Snowflake instance. | |
To use, specify the 6 constants defined at the top: | |
SNOWFLAKE_ACCOUNT, SNOWFLAKE_USERNAME, SNOWFLAKE_PASSWORD, and SNOWFLAKE_DATABASE come from https://app.mozartdata.com/integrations/mode | |
TARGET_SCHEMA and TARGET_TABLE are where we'll be writing to | |
CSV_FILEPATH is the full path to the csv file we'll be uploading | |
Install snowflake-sqlalchemy: https://docs.snowflake.com/en/user-guide/sqlalchemy.html#installing-snowflake-sqlalchemy | |
tldr: pip install --upgrade snowflake-sqlalchemy |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
import simplejson as json | |
import requests | |
#your spreadsheet key here. I'm using an example from the Victorian election campaign | |
key = "1THJ6MgfEk-1egiPFeDuvs4qEi02xTpz4fq9RtO7GijQ" | |
#google api request urls - I'm doing the first one just to get nice key values (there's probably a better way to do this) | |
url1 = "https://spreadsheets.google.com/feeds/cells/" + key + "/od6/public/values?alt=json" |