1

I picked up O'Reiley's Data Wrangling with Python by Jacqueline Kazil and Katherine Karmul. In ch.5, pg.94, I'm running the following code.

import slate

pdf = 'EN-FINAL Table 9.pdf'

with open(pdf) as f:
    doc = slate.PDF(f)

for page in doc[:2]:
    print page

I'm using Windows 10, Python 2.7.12 , running slate 0.5.2, pdfminer 20140328 and successfully installed pip. I got the following result:

File "C:\Python27\lib\site-packages\pdfminer\psparser.py", line 215, in fillbuf
    raise PSEOF('Unexpected EOF')
 pdfminer.psparser.PSEOF: Unexpected EOF

I only know that EOF means 'end of file' and no more data can be read from data source. Does anybody have an idea as to what happened?

If anybody would like to see what file I'm trying to parse, it's right here: https://github.com/jackiekazil/data-wrangling/tree/master/data/chp5

jjjack1
  • 11
  • 1
  • 4
  • Why do you post text as image (with tons of unrelated information)? – Psytho Aug 26 '16 at 13:04
  • Hi, Alex. I don't get what you mean by this. I'm following the tutorial in the book and I'm supposed to be able to run this code once I've installed slate and pdfminer. – jjjack1 Aug 26 '16 at 13:11
  • Your error code is text but you post it here as screenshot of your entire display. Copy the error message and paste it here as text. – Psytho Aug 26 '16 at 13:14
  • I took a screenshot because I had trouble getting my computer to copy&paste before it ran out of power. Also, I can't tell if the information is unrelated or not since I'm new to programming. – jjjack1 Aug 26 '16 at 13:25

1 Answers1

1

This solved it for me: https://stackoverflow.com/a/18262661/6843645

Your code would be:

import slate

pdf = 'EN-FINAL Table 9.pdf'
with open(pdf, 'rb') as f:
    doc = slate.PDF(f)

for page in doc[:2]:
    print page
Community
  • 1
  • 1
neonB
  • 11
  • 2