我在输入文件中有一个MARC21记录。我正试着用Aleph顺序格式打印它。
多么?
我想打印记录号码(9位),空格,字段标签,指示器,空格,L字母,空格,然后每个子字段标签和子字段竞赛。
我正在尝试使用record.get_fields(),但是我没有成功地获得字段指示符和子字段标记。
我是如何得到和打印字段指示符的?如何打印ech子字段标记,然后打印每个子字段值?
这是我的代码:
from pymarc import MARCReader
from pymarc import Record, Field
with open('machiavellism_biu_2018.mrc', 'rb') as fh:
reader = MARCReader(fh, to_unicode=True)
# loop 1
recnum = 0
for record in reader:
# loop 2
recnum += 1
for tield_contents in record.get_fields():
print ('%09d' % recnum,' ',tield_contents.tag,' ',' L',tield_contents.value())
## end loop 2
输出的一个例子:
python pymarc_000002.py
..。
000000001 001 L 002547390
000000001 003 L OCoLC
000000001 005 L 20181016125657.0
000000001 008 L 180214t20182018enka b 001 0 eng
000000001 092 L 302 BER m
000000001 020 L 9781138093317
000000001 035 L (OCoLC)991673448
000000001 040 L eng rda
000000001 041 L eng
000000001 100 L Bereczkei, Tamás lat author
000000001 245 L Machiavellianism : the psychology of manipulation / Tamas Bereczkei.
000000001 264 L London : Routledge, 2018.
000000001 264 L ©2018
发布于 2019-02-11 21:07:31
如果marc字段有第一个或第二个指示符,那么它将被解析为.indicator1
或.indicator2
属性。即使在marc记录中只定义了一个,它们都将被定义,所以类似的事情应该可以工作。
if hasattr(field_contents, 'indicator1'):
indicator1 = field_contents.indicator1
indicator2 = field_contents.indicator2
https://stackoverflow.com/questions/54284595
复制相似问题