Skip to content

Instantly share code, notes, and snippets.

@anarchivist
Created December 13, 2009 03:41
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 anarchivist/255248 to your computer and use it in GitHub Desktop.
Save anarchivist/255248 to your computer and use it in GitHub Desktop.
loop over a series of MARC files to extract record numbers, with hints to figure out which records are missing them
# loop over a series of MARC files to extract record numbers, with hints to figure out which records are missing them
import pymarc
c = 0
w = open('ids','w')
for f in ('hspall', 'lcpraream', 'lcprarenot', 'lcpnotrare'):
r = pymarc.MARCReader(file(f))
for _ in r:
c += 1
try:
w.write(_['001'].format_field() + '\n')
except AttributeError:
w.write('==missing\n')
a = pymarc.map_marc8_record(_)
print a.__str__().encode('utf-8')
raw_input()
if (c % 1000 == 0):
print c
w.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment