Last active
August 29, 2015 14:04
-
-
Save jalavik/40012deb4fadd3c2a402 to your computer and use it in GitHub Desktop.
How to match incoming records on recid in 035
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def attempt_record_match(recid): | |
""" Tries to find out if the record is already in Inspire """ | |
return perform_request_search(p="035:CDS and 035:%s" % (recid,), of="id") | |
for record in records: | |
# Step 1: Attempt to match the record to those already in Inspire | |
try: | |
recid = record['001'][0][3] | |
res = attempt_record_match(recid) | |
except (KeyError, IndexError) as err: | |
print('Error: Cannot process record without 001:recid') | |
error_records.append(record) | |
continue | |
if skip_recid_check or not res: | |
print("Record %s does not exist: inserting" % (recid,)) | |
# Step 2: Appply filter to transform CDS MARC to Inspire MARC | |
insert_records.append(apply_filter(record)) | |
else: | |
print("Record %s found: %r" % (recid, res)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment