comparison parse.py @ 51:793496d2d165

allow command line input
author Henry S. Thompson <ht@markup.co.uk>
date Tue, 16 May 2017 17:27:19 +0100
parents e500d7c18aad
children
comparison
equal deleted inserted replaced
50:01a7c2ebd3d1 51:793496d2d165
1 #!/usr/bin/python2.7
1 ''' Tokenise Excel formulae 2 ''' Tokenise Excel formulae
2 Starting from regexps and concat rules in 3 Starting from regexps and concat rules in
3 https://sites.google.com/site/e90e50/random-topics/tool-for-parsing-formulas-in-excel 4 https://sites.google.com/site/e90e50/random-topics/tool-for-parsing-formulas-in-excel
4 and 5 and
5 parser_formule_with_textbox_v01_2003.xla 6 parser_formule_with_textbox_v01_2003.xla
47 # (suitably int'lised) 48 # (suitably int'lised)
48 49
49 tokPat=re.compile("("+(")|(".join(pats))+")",re.IGNORECASE) 50 tokPat=re.compile("("+(")|(".join(pats))+")",re.IGNORECASE)
50 51
51 f="""=IF(I$1>$C$2,VLOOKUP($C52,GP_input!$C$187:$CM$196,VLOOKUP($C$9,lists!$A$34:$B$39,2,FALSE)+BC$4,FALSE),SUMIF('BEX2011'!$C$32:$C$5000,$B$9&"sl"&$B52&$C52&$B53,'BEX2001'!Q$32))""" 52 f="""=IF(I$1>$C$2,VLOOKUP($C52,GP_input!$C$187:$CM$196,VLOOKUP($C$9,lists!$A$34:$B$39,2,FALSE)+BC$4,FALSE),SUMIF('BEX2011'!$C$32:$C$5000,$B$9&"sl"&$B52&$C52&$B53,'BEX2001'!Q$32))"""
53
54 if len(sys.argv)>1:
55 f=sys.argv[1]
52 56
53 l=tokPat.findall(f) 57 l=tokPat.findall(f)
54 58
55 ## Visual basic code: 59 ## Visual basic code:
56 ## set M = RE.Execute(s) 60 ## set M = RE.Execute(s)