-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcap.py
More file actions
23 lines (21 loc) · 846 Bytes
/
Copy pathcap.py
File metadata and controls
23 lines (21 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pymarc import MARCReader
def main():
with open('input_mrc/input.mrc', 'rb') as fh:
# Open the record and encode as unicode, to prevent errors
reader = MARCReader(fh, to_unicode=True, force_utf8=True)
count = 0
for record in reader:
for field in record.fields:
if field.tag in ['006', '007']:
o = field.__str__()
if not field.data.islower():
field.data = field.data.lower()
count += 1
if field.tag == '007':
print(field.data)
# # Write the edited record to a new file
# with open('output_mrc/006mangled.mrc', 'ab') as out:
# out.write(record.as_marc())
print(count)
if __name__ == '__main__':
main()