Parsing Nested List

Stanley Denman dallasdisabilityattorney at gmail.com
Sun Feb 4 17:26:10 EST 2018


I am trying to parse a Python nested list that is the result of the getOutlines() function of module PyPFD2 using pyparsing module. This is the result I get. what in the world are 'expandtabs' and why is that making a difference to my parse attempt?

Python Code
7
import PPDF2,pyparsing
from pyparsing import Word, alphas, nums
pdfFileObj=open('x.pdf','rb')
pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
List=pdfReader.getOutlines()
myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2)
myparser.parseString(List)

This is the error I get:

Traceback (most recent call last):
  File "<pyshell#23>", line 1, in <module>
    myparser.parseString(List)
  File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString
    instring = instring.expandtabs()
AttributeError: 'list' object has no attribute 'expandtabs'

Thanks so much, not getting any helpful responses from https://python-forum.io.



More information about the Python-list mailing list