edsu / pymarc

process MARC records from Python
http://python.org/pypi/pymarc
Other
253 stars 98 forks source link

Exception at the end of iterating through a marc file. #97

Open cshintov opened 8 years ago

cshintov commented 8 years ago

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

Wooble commented 8 years ago

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?

cshintov commented 8 years ago

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 https://github.com/edsu/pymarc/issues/97#issuecomment-242439403, or mute the thread https://github.com/notifications/unsubscribe-auth/AK1uDEL-iYiPnPUjTUnKpOACMl7O4Nv0ks5qjbrEgaJpZM4JtKxM .

edsu commented 7 years ago

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?