IndexError: string index out of range (when reproducing your example)
blay opened this issue · 4 comments
Ubuntu 18.04, Python 2.7 (although also tried with 3.5), poppler and pip-dependencies installed.
-
A regular papers install, no problems
papers install --bibtex papers.bib --filesdir files --git --gitdir ./ -
Download your papers and try to extract from it, get error message
papers add --rename --copy --bibtex papers.bib --filesdir files esd-4-11-2013.pdf --info
NFO:papers:bibtex: papers.bib
INFO:papers:filesdir: files
Traceback (most recent call last):
File "/usr/local/bin/papers", line 5, in
papers.bib.main()
File "/usr/local/lib/python2.7/dist-packages/papers/bib.py", line 1343, in main
check_install() and addcmd(o)
File "/usr/local/lib/python2.7/dist-packages/papers/bib.py", line 942, in addcmd
my = Biblio.load(o.bibtex, o.filesdir)
File "/usr/local/lib/python2.7/dist-packages/papers/bib.py", line 258, in load
return cls(bibtexparser.loads(bibtexs), filesdir)
File "/usr/local/lib/python2.7/dist-packages/papers/encoding.py", line 12, in
bibtexparser.loads = lambda s: _bloads(s.decode('utf-8') if type(s) is str else s)
File "/usr/local/lib/python2.7/dist-packages/bibtexparser/init.py", line 48, in loads
return parser.parse(bibtex_str)
File "/usr/local/lib/python2.7/dist-packages/bibtexparser/bparser.py", line 145, in parse
bibtex_file_obj = self._bibtex_file_obj(bibtex_str)
File "/usr/local/lib/python2.7/dist-packages/bibtexparser/bparser.py", line 213, in _bibtex_file_obj
if bibtex_str[0] == byte:
IndexError: string index out of range
Any clues? And thanks for what looks like such a great way to manage a bibliography!
Hi ! Looks like it's due to an update to bibtexparser dependency.
pip install bibtexparser==0.6.2
solves the bug (as a temporary patch of course).
Let me find out what is going on.
I have got the same error. I wanted to read a large BibTeX file and I have the following error. Pls help me fix this.
IndexError Traceback (most recent call last)
in
3
4 with open('BibTexFile_randomly_selected_excluded.bib') as bibtex_file:
----> 5 bib_database = bibtexparser.load(bibtex_file)
6
7 #print(bib_database.entries)
C:\ProgramData\Anaconda3\envs\wcrf\lib\site-packages\bibtexparser_init_.py in load(bibtex_file, parser)
69 if parser is None:
70 parser = bparser.BibTexParser()
---> 71 return parser.parse_file(bibtex_file)
72
73
C:\ProgramData\Anaconda3\envs\wcrf\lib\site-packages\bibtexparser\bparser.py in parse_file(self, file, partial)
175 :rtype: BibDatabase
176 """
--> 177 return self.parse(file.read(), partial=partial)
178
179 def _init_expressions(self):
C:\ProgramData\Anaconda3\envs\wcrf\lib\site-packages\bibtexparser\bparser.py in parse(self, bibtex_str, partial)
151 :rtype: BibDatabase
152 """
--> 153 bibtex_file_obj = self._bibtex_file_obj(bibtex_str)
154 try:
155 self._expr.parseFile(bibtex_file_obj)
C:\ProgramData\Anaconda3\envs\wcrf\lib\site-packages\bibtexparser\bparser.py in _bibtex_file_obj(self, bibtex_str)
223 if isinstance(bibtex_str, ustr):
224 byte = ustr(byte, self.encoding, 'ignore')
--> 225 if bibtex_str[0] == byte:
226 bibtex_str = bibtex_str[1:]
227 else:
IndexError: string index out of range
Sorry I am a little slow to respond to issues. If you provided me with you bibtex file, I can take a look at what might be causing the error.