Skip to content

Instantly share code, notes, and snippets.

@bmcbride
Last active October 13, 2017 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmcbride/592777220b7bd141d517 to your computer and use it in GitHub Desktop.
Save bmcbride/592777220b7bd141d517 to your computer and use it in GitHub Desktop.
Update Fulcrum records from a CSV file.
import csv
from fulcrum import Fulcrum
from fulcrum.exceptions import NotFoundException
api_key = 'your-api-key'
form_id = 'your-form-id'
fulcrum = Fulcrum(key=api_key)
updates = csv.reader(open('record-updates.csv'), delimiter=',')
# skip header
next(updates, None)
# loop through CSV records
for row in updates:
# fetch existing record
try:
data = fulcrum.records.find(row[0])
except NotFoundException:
print 'No record found with id ' + row[0]
continue
# update fields with CSV values
data['record']['form_values']['9d69'] = row[5]
data['record']['form_values']['1299'] = row[6]
# send updates back to Fulcrum
record = fulcrum.records.update(row[0], data)
print 'Record ' + row[0] + ' successfully updated!'
@hgarcia6104
Copy link

Hi Bryan i'm a newby in this area and trying to learn, is this script assuming that the CSV is ready to be uploaded right?

So the full process will be to download the outdated records on a CSV, update de records and then apply the script right?

Thanks

Hector Garcia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment