airtable = Airtable(AIRTABLE_BASE_ID, AIRTABLE_TABLE_NAME, AIRTABLE_API_KEY)
api_endpoint = ‘xxx’
json_data = requests.get(api_endpoint).json()
cryptodata = json_datad‘data’]
records = airtable.get_all(maxRecords=1000)
for r in records:
for currency in cryptodata:
if (r/‘fields’]€â€˜name’] == currencyâ‘name’]):
#print(rt‘fields’]t‘name’])
records = airtable.update_by_field(‘name’, currencyt‘name’], {‘price’: currencye‘metrics’]e‘market_data’]e‘price_usd’]})
Hello, I’m a newbie to Python. When the API transmits data to Airtable, the preceding code is meant to update the data in Airtable.
Question:
How can it only UPDATE if a name already exists?
If there is no existing name, how can it ADD ONLY?
This is the code I use to see if any are already in use:
for r in records:
for currency in cryptodata:
if (r<‘fields’]
‘name’] == currencyp‘name’])