Skip to content

Instantly share code, notes, and snippets.

@cmharlow
Last active January 20, 2017 21:13
Show Gist options
  • Save cmharlow/fe49d4a85a437df42795b97d955d6af0 to your computer and use it in GitHub Desktop.
Save cmharlow/fe49d4a85a437df42795b97d955d6af0 to your computer and use it in GitHub Desktop.
for javed.
#!/usr/bin/env python
import pymarc
import sys
input = sys.argv[1]
output = input + '.xml'
reader = pymarc.MARCReader(open(input, 'rb'), to_unicode=True)
with open(output, 'w') as writer:
writer.write("<collection xmlns='http://www.loc.gov/MARC21/slim'>")
for record in reader:
record.leader = record.leader[:9] + 'a' + record.leader[10:]
writer.write(pymarc.record_to_xml(record).decode('utf-8') + "\n")
writer.write("</collection>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment