-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added documentation for python scripts
- Loading branch information
1 parent
2893e24
commit 79fb662
Showing
4 changed files
with
378 additions
and
223 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
import os | ||
import pyairtable | ||
import json | ||
LEGISLATION_INFO = os.environ['LEGISLATION_INFO'] | ||
api = pyairtable.Api(LEGISLATION_INFO) | ||
table = api.table('apps7I6q0g9Hyb6j9','tblydWhHOZeqjzycO') | ||
legislation = table.all() | ||
legislation_list = [x['fields'] for x in legislation] | ||
with open("public/legislations_info.json", "w") as outfile: | ||
json.dump(legislation_list, fp = outfile,indent = 4) | ||
|
||
def generate_legislation_info(API_KEY, APP_KEY, TBL_KEY): | ||
""" | ||
Generates legislation information and saves it to a JSON file. | ||
This function retrieves legislation information from an Airtable database, | ||
converts it to a list of dictionaries, and saves it to a JSON file for the front-end to access. | ||
Args: | ||
API_KEY (str): The API key for accessing the Airtable database. | ||
APP_KEY (str): The application key for accessing the Airtable database. | ||
TBL_KEY (str): The table key for accessing the specific table in the Airtable database. | ||
Returns: | ||
None | ||
""" | ||
api = pyairtable.Api(API_KEY) | ||
table = api.table(APP_KEY, TBL_KEY) | ||
legislation = table.all() | ||
legislation_list = [x['fields'] for x in legislation] | ||
with open("public/legislations_info.json", "w") as outfile: | ||
json.dump(legislation_list, fp=outfile, indent=4) | ||
|
||
if __name__ == '__main__': | ||
API_KEY = os.environ['LEGISLATION_INFO'] | ||
generate_legislation_info(API_KEY, 'apps7I6q0g9Hyb6j9', 'tblydWhHOZeqjzycO') |
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
Oops, something went wrong.