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 functions as a brief introduction to Parsons. To install Parsons, follow this | |
guide: https://parsons.pubpub.org/installation. If you're used to installing with pip, the tldr is | |
"pip install parsons". | |
""" | |
# print("Let's do this!") | |
""" | |
This is a Parsons Table. It's how we store data using Parsons. You can create a Table from a variety of sources, |
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
import petl | |
from parsons import Redshift, Table | |
from parsons.utilities.files import close_temp_file | |
from canalespy import logger | |
VALID_STRATEGIES = ['copy', 'local_file', 'upsert'] | |
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
# Here's some data to play with! | |
data = [ | |
{'first_name': 'Megan', 'last_name': 'Rapinoe', 'age': '37', 'date_updated': '1674121763'}, | |
{'first_name': 'Tobin', 'last_name': 'Heath', 'age': '34', 'date_updated': '1664121763'}, | |
{'first_name': 'Crystal', 'last_name': 'Dunn', 'age': '31', 'date_updated': '1664121763'}, | |
{'first_name': 'Midge', 'last_name': 'Purce', 'age': '26', 'date_updated': '1664121763'}, | |
{'first_name': 'Sophia', 'last_name': 'Smith', 'age': '23', 'date_updated': '1664121763'} | |
] |
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
############# | |
### SETUP ### | |
############# | |
from parsons import MobilizeAmerica, GoogleSheets | |
mobilize = MobilizeAmerica() | |
sheets = GoogleSheets() # don't forget to set GOOGLE_DRIVE_CREDENTIALS environmental variable |
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
from parsons import MobilizeAmerica, ActionNetwork, GoogleSheets, Table | |
######################### | |
### Getting your data ### | |
######################### | |
"""Typically you'd load data directly from your third party platform:""" | |
# mobilize = MobilizeAmerica() |
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
############################## | |
### Get data from Mobilize ### | |
############################## | |
from parsons import MobilizeAmerica | |
"""Don't forget to set the MOBILIZE_AMERICA_API_KEY environment variable""" | |
mobilize = MobilizeAmerica() | |
mobilize.uri = "https://staging-api.mobilize.us/v1/" # only necessary since we're using a "developer sandbox" |
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 functions as a brief introduction to Parsons. To install Parsons, follow this | |
guide: https://parsons.pubpub.org/installation. If you're used to installing with pip, the tldr is | |
"pip install parsons". | |
""" | |
# print("Let's do this!") |
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
#----------------------------------------------------------- | |
# Import Necessary Packages | |
#----------------------------------------------------------- | |
import json | |
from parsons import Table, MobilizeAmerica, GoogleSheets | |
from datetime import datetime | |
#----------------------------------------------------------- | |
# Instantiate Classes/Connect to Mobilize and Google Sheets |
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 script was created for the Parsons "All About Authentication" training. | |
""" | |
from parsons import Table, Twilio, GoogleSheets | |
twilio = Twilio() | |
sheets = GoogleSheets() | |
# Get data from google sheets |
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
from parsons import Table | |
# Download NC Voter data file from: https://s3.amazonaws.com/dl.ncsbe.gov/data/ncvoter_Statewide.zip | |
# Extract (very large, I had to use an external haard drive) | |
# load the file into a Parsons table | |
# note #1 - need to specify encoding as it's not default UTF-8 | |
# used "file -i ncvoter_Statewide.txt" on Linux to find file's encoding which was charset=iso-8859-1 | |
# python codecs list says charset=iso-8859-1 is called latin_1 |
NewerOlder