osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parsing Nested List


On Sunday, February 4, 2018 at 4:26:24 PM UTC-6, Stanley Denman wrote:
> 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.