Skip to content

Instantly share code, notes, and snippets.

@cgalo5758
Created September 16, 2024 06:32
Show Gist options
  • Select an option

  • Save cgalo5758/7309fde50428112e212d481373588c17 to your computer and use it in GitHub Desktop.

Select an option

Save cgalo5758/7309fde50428112e212d481373588c17 to your computer and use it in GitHub Desktop.
Create Airtable singleLineText fields in bulk
from pyairtable import Api
import os
# Replace these with your Airtable API key and Base ID
AIRTABLE_API_KEY = 'YOUR_API_KEY_HERE'
AIRTABLE_BASE_ID = 'YOUR_AIRTABLE_BASE_ID_HERE'
TABLE_ID = 'YOUR_TABLE_ID_HERE'
# Initialize the Airtable table
api = Api(AIRTABLE_API_KEY)
base = api.base(AIRTABLE_BASE_ID)
table = base.table(TABLE_ID)
# Path to your input file
file_path = 'variables'
# Read the file and create a field for each line
with open(file_path, 'r') as file:
for line in file:
field_name = line.strip()
if field_name:
try:
# Create a new field with the line content as the field name
table.create_field(name=field_name, type='singleLineText')
print(f"Field '{field_name}' created successfully.")
except Exception as e:
print(f"Error creating field '{field_name}': {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment