Closed fanchyna closed 5 years ago
Did you imported given libraries also?
I can confirm that test code prints nothing. Tested on cygwin with python 2.7.14
$ pip install RISparser
$ pip list | grep "RISparser"
RISparser 0.4.3
$ cat > test.ris<<EOF
1.
TY - JOUR
ID - 12345
T1 - Title of reference
A1 - Marx, Karl
A1 - Lindgren, Astrid
A2 - Glattauer, Daniel
Y1 - 2014//
N2 - BACKGROUND: Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
KW - Pippi
KW - Nordwind
KW - Piraten
JF - Lorem
JA - lorem
VL - 9
IS - 3
SP - e0815
CY - United States
PB - Fun Factory
PB - Fun Factory USA
SN - 1932-6208
M1 - 1008150341
L2 - http://example.com
ER -
EOF
$ python
Python 2.7.14 (default, Oct 31 2017, 21:12:13)
[GCC 6.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import os
>>> from pprint import pprint
>>> from RISparser import readris
>>> filepath = 'test.ris'
>>> with open(filepath, 'r') as bibliography_file:
... entries = readris(bibliography_file)
... print [i for i in entries]
... for entry in entries:
... print(entry)
... print(entry['id'])
... print(entry['first_authors'])
...
[]
>>>
This doesn't look right, I'll take a look
I looked into this @me-kell; my guess is the print statement is messing this up. When you print i for i in entries, it'll exhaust the iterator, so that when you try to iterate over it again, it's empty and that's why you get an empty list. If you wrap readris in a list, entries = list(readris(bibliography_file)
, it'll return a list of entries instead of a generator.
@fanchyna I'm not sure what is not working for you; I know that this code works because it's baked into our testing system to run the readme. Let me know if you can provide more details.
I tried the example. The RIS file content was copied into a text file. The statements are executed on the command line, but nothing prints: