Pablo
unread,Jun 5, 2012, 11:22:51 AM6/5/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pym...@googlegroups.com
Dear list members,
I am trying to remove some fields from some authority records I need to import in my system.
For this I read the record and write every field (except those that I need to skip) to a new file.
The problem is that when I want to write the leader information I get the following exeption.
Message File Name Line Position
exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 58: ordinal not in range(128)
this is my code and attached is the marc file I am using to test the script:
output = open('file.dat','w')
record = Record()
reader = MARCReader(file('espionage.mrc') , to_unicode=False)
for readrecord in reader:
l = list(record.leader)
l[5] = 'n'
l[6] = 'z'
l[9] = 'a'
l[17]= 'n'
record.leader = ("".join(l))
for field in readrecord:
if field.tag != '016' and field.tag != '697':
record.add_field(field)
output.write(record.as_marc())
output.close()
It seems it does not like the encoding on the leader but I don't know how to change it.
It is probably obvious that I am not very experienced in scripting, so any help is greatly appreciated.
Pablo