Skip to content

Commit

Permalink
add if so we don't test empty matches
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbradshaw committed Jan 18, 2017
1 parent 7f56dd1 commit 08976b2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scraper.py
Expand Up @@ -41,12 +41,14 @@
#Now the date, which is in <text top="224" left="661" width="147" height="18" font="2"
dateinspected = pdfroot.findall('.//text[@top="224"]')
for i in dateinspected:
print i.text.encode('ascii','ignore')
if i is not None:
print 'DATE MATCH? ', i.text.encode('ascii','ignore')

#loop through each item in 'lines'
for line in lines:
linenumber = linenumber+1
#we are not interested in lines that are empty, so this if test ensures the line after only runs if it's not empty
#Otherwise we might get AttributeError: 'NoneType' object has no attribute 'encode'
if line.text is not None:
#use regex to look for any or no character(s) followed by the string 'incident'
#followed by any or no character(s) - the result is stored in 'mention'
Expand Down

0 comments on commit 08976b2

Please sign in to comment.