Closed getmykhan closed 4 years ago
I would be interested in functionality that would let me push a pandas dataframe to airtable. Especially if it handles the filetype conversions. :D
Do you already have something like that working outside the library? Curious how much code is required to add the feature.
Nope. Thinking of something along the lines of a strict JSON to bulk insert to airtables. Not sure if that is the most efficient way to do it though!
Just a few tries if it can help. For reading :
from airtable import Airtable
import pandas as pd
airtable = Airtable( base key, table_name, api_key = 'XXXX')
record_list = airtable.get_all()
df = pd.DataFrame([record['fields'] for record in record_list])
Or with index as record ID
df = pd.DataFrame([record['fields'] for record in record_list], index = [record['id'] for record in record_list])
For writing a row from DataFrame :
record=df.iloc[i].to_dict()
airtable.batch_insert([record])
Of course handling missing data, links between table may be more complicated
we could add a snippet to doc on how to do this but won't add any pandas functionality to the lib
Would you guys be interested in loading the data directly into pandas and then pushing it out back to Airtable
Thoughts?