updating the leader

43 views
Skip to first unread message

wells....@gmail.com

unread,
Aug 17, 2022, 6:48:31 PM8/17/22
to pymarc Discussion
Hey everyone,

I'm trying to replace all instances of the leader with the same uniform text.  This code works when I print the records to the console, but not when I open the mrc file in marcedit.  Any help is much appreciated! Thank you!

with open(input('Enter file: '), 'rb') as marcfile:
    reader = MARCReader(marcfile, utf8_handling='ignore', file_encoding='latin-1')
    writer = MARCWriter(open(input('Enter outputfile: '),'wb')) #, force_utf8=True)

    for record in reader:
        try:

            leader = Leader('     nz   22     n  4500')
            record.leader = leader
            # print(record.leader)


        except UnicodeEncodeError:
            continue


        print(record)

        writer.write(record)


    writer.close()


Reply all
Reply to author
Forward
0 new messages