edsu / pymarc

process MARC records from Python

Home Page:http://python.org/pypi/pymarc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception at the end of iterating through a marc file.

cshintov opened this issue · comments

When I am Iterating through a marc file containing multiple MARC records, After the last record the following exception is raised.
Traceback (most recent call last):
File "compare_marcs.py", line 320, in
pprint(compare_marc_files(exp, obs))
File "compare_marcs.py", line 299, in compare_marc_files
for exp_marc, obs_marc in izip(expected, observed):
File "/home/shinto/shinto/virtualenvs/marc/local/lib/python2.7/site-packages/six.py", line 558, in next
return type(self).next(self)
File "/home/shinto/shinto/virtualenvs/marc/local/lib/python2.7/site-packages/pymarc/reader.py", line 97, in next
utf8_handling=self.utf8_handling)
File "/home/shinto/shinto/virtualenvs/marc/local/lib/python2.7/site-packages/pymarc/record.py", line 74, in init
utf8_handling=utf8_handling)
File "/home/shinto/shinto/virtualenvs/marc/local/lib/python2.7/site-packages/pymarc/record.py", line 245, in decode_marc
raise BaseAddressInvalid
pymarc.exceptions.BaseAddressInvalid: Base address exceeds size of record

It sounds like your file might be cut off before the end of the last record, or at least pymarc thinks so. How are you opening the file and creating the reader?

Hi I am opening the files using 'with' .
exp and obs are the two marc files.

with open(exp) as exp_marcs, open(obs) as obs_marcs:
for exp_marc, obs_marc in izip(expected, observed):
do stuff

Thanks,
Shinto.

On Thu, Aug 25, 2016 at 9:24 PM, Geoffrey Spear notifications@github.com
wrote:

It sounds like your file might be cut off before the end of the last
record, or at least pymarc thinks so. How are you opening the file and
creating the reader?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#97 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AK1uDEL-iYiPnPUjTUnKpOACMl7O4Nv0ks5qjbrEgaJpZM4JtKxM
.

That's an interesting way to do it. And by interesting I mean I have no idea what it does :-) Can you explain what's going on there?