added possibility to use comma in functions, to prevent splitting substituted by ';'. Eg. round(4.021,1) becomes round(4.021;1) in command line call

This commit is contained in:
Mahesh Balasubramaniam 2012-08-22 17:47:34 +00:00
parent bdf58c6268
commit 975c3437ac
1 changed files with 6 additions and 2 deletions

View File

@ -29,9 +29,9 @@ class extendableOption(Option):
parser = OptionParser(option_class=extendableOption, usage='%prog options [file[s]]', description = """
Add column(s) with derived values according to user defined arithmetic operation between column(s).
Columns can be specified either by label or index.
Columns can be specified either by label or index. Use ';' for ',' in functions.
Example: distance to IP coordinates -- "math.sqrt( #ip.x#**2 + #ip.y#**2 + #ip.z#**2 )"
Example: distance to IP coordinates -- "math.sqrt( #ip.x#**2 + #ip.y#**2 + round(#ip.z#;3)**2 )"
""" + string.replace('$Id$','\n','\\n')
)
@ -48,6 +48,10 @@ parser.set_defaults(formulas= [])
if len(options.labels) != len(options.formulas):
parser.error('number of labels (%i) and formulas (%i) do not match'%(len(options.labels),len(options.formulas)))
for i in xrange(len(options.formulas)):
options.formulas[i]=options.formulas[i].replace(';',',')
# ------------------------------------------ setup file handles ---------------------------------------
files = []