airtable-cfc-content-review
Pull data from AirTable and then format it into a PHP array for compatibility with our IBM website.
Instead of filtering and searching for records with multiple statuses in Python, use AirTable "Views" to filter everything, call that view programmatically, and read the records.
This project uses the AirTable Python Wrapper - https://github.com/gtalarico/airtable-python-wrapper
Notes
- For any record, if
Asset Type
has more than one item in it, this program will ONLY choose the first item. If you want to change the category that a topic appears in, change the first item inAsset Type
in AirTable.
How-to's
To add a table:
- Add the table name to the list in
line 7
. - Create a list in the
# Create defaultdict structures
section by copying and pasting an existing list under the other variables and changing the variable name. - Find this code in the
# Place data from the table in the correct list
section, copy it, and add it after the lastelif
statement.
elif table is 'Disaster Domain':
disaster_domain_records_list[asset_type].append(topic_list)
- Change
Disaster Domain
to your table name you added in Step 1. - Change
disaster_domain_records_list
to the variable name you made in Step 2.
- Find this code in
line 149
, copy it, and add it after the lastcreatePHPpage(...)
entry
createPHPpage(technical_domain_records_list, '_technical-content')`
- Change
technical_domain_records_list
to your variable name you made in Step 2. - Change
_technical-content
to the name of the file you want to generate.
To delete a table and associated code:
- Remove the corresponding table name in the list in
line 7
. - Remove the corresponding variable under the
# Create defaultdict structures
section. - Remove the corresponding code in the
# Place data from the table in the correct list
section. - Remove the corresponding code at the end of the file that calls the
createPHPpage
method.
To change the View used by the program
- Create the View you want in AirTable
- Change
Keep
to your view name in this coderecords = airtable.get_all(view='Keep')