Skip to content

Commit

Permalink
Update convert_airtable_to_csv.py
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelduranfrigola authored Feb 8, 2024
1 parent 4ce17eb commit 664c14d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/scripts/convert_airtable_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ def convert_airtable_to_csv(airtable_api_key, airtable_base_id,airtable_table_id
base = Airtable(airtable_base_id, airtable_table_id, airtable_api_key)
records = base.get_all()
with open(file_path, 'w') as f:
print("Writing to {0}".format(file_path))
writer = csv.writer(f)
writer.writerow(records[0]["fields"].keys())
for record in records:
writer.writerow(record["fields"].values())

if __name__ == "__main__":

print("Getting environmental variables")
airtable_api_key = os.environ.get('AIRTABLE_API_KEY')
airtable_base_id = os.environ.get('AIRTABLE_BASE_ID')
airtable_table_id = os.environ.get('AIRTABLE_TABLE_NAME')

convert_airtable_to_csv(airtable_api_key, airtable_base_id,airtable_table_id, file_path)
print("Converting AirTable base to CSV file")
convert_airtable_to_csv(airtable_api_key, airtable_base_id,airtable_table_id, file_path)

0 comments on commit 664c14d

Please sign in to comment.