Created
October 27, 2011 15:29
-
-
Save miku/1319893 to your computer and use it in GitHub Desktop.
Basic pymarc usage example.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Example usage: python simpledump.py 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 | |
else: | |
print field.data | |
print '-' * 48 | |
if __name__ == '__main__': | |
try: | |
dump(sys.argv[1]) | |
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