| Paste number 44689: | edsu: marc8 to utf8 sample for pymarc |
| Pasted by: | anarchivist |
| When: | 1 year, 11 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+YHD |
| Channel: | #code4lib |
| Paste contents: |
from pymarc import *
import sys
def marc8_to_utf( marc8string ):
converter = MARC8_to_Unicode()
converted = converter.translate(marc8string)
converted = unicodedata.normalize('NFC', converted)
return converted
reader = MARCReader(file(sys.argv[1]))
titlefile = open(sys.argv[2], 'w')
for record in reader:
marc8title = record['245'].value()
utf8title = marc8_to_utf(marc8title)
titlefile.write(utf8title.encode("utf8"))
titlefile.write('\n')
titlefile.close()This paste has no annotations.