Hello
Apologies for a very basic question - but I am running into a wall with some code.
I am very new to Python and PyMARC.
I am trying to use PyMARC to pull a list of 035's from a list of MARC21 records. I want to have the list of 035's to output to a text file.
My code thus far:
# List all OCLC numbers in the file
import pymarc
from pymarc import MARCReader
with open(r'C:\Users\RickRigby\Desktop\RichardLGuinninterests\metadataMARC.mrc','rb') as fh:
reader = MARCReader(fh)
for record in reader:
print(record['035'])
from pymarc import MARCWriter
ARN = record.get_fields('035')
ARNfile = open(r'C:\Users\RickRigby\Desktop\RichardLGuinninterests\metadata.mrk','w')
ARNfile.write(str(ARN))
ARNfile.close()?
it creates a text file but with nothing in the file.
How can I get this to work?
Also - I would like a list in the text file but when I use just ARNfile.write(ARN)
I get a TypeError: TypeError: write() argument must be str, not list
I'm not sure if there's a way to get around that...
Thank you very much for any help!
Richard
|