Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Basic pymarc usage example.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
Example usage: python data/marc/010-lok.mrc
import pymarc
import sys
def dump(filename):
reader = pymarc.MARCReader(file(filename))
for record in reader:
print 'Leader ==>', record.leader
for field in record:
print field.tag, '|',
if hasattr(field, 'subfields'):
print 'Indicators ==>', field.indicators,
print 'Subfields ==>', field.subfields
print '-' * 48
if __name__ == '__main__':
except IndexError:
print 'usage: %s FILENAME' % sys.argv[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment