我在输入文件中有一个MARC21记录。 我试着用Aleph顺序格式打印。在
怎么做的?
我要打印记录号(9位数字)、空格、字段标记、指示符、空格、L字母、空格,然后再打印每个子字段标记和子字段竞赛。在
我想用record.get_字段(),但我无法成功获取字段指示符和子字段标记。在
如何获取和打印字段指示器? 如何打印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
输出示例:
^{pr2}$。。。在
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
如果marc字段有第一个或第二个指示符,那么它将被解析为}属性。即使在marc记录中只定义了一个,它们都将被定义,所以类似这样的方法应该可以工作。在
.indicator1
或{相关问题 更多 >
编程相关推荐