zeroSteiner / rule-engine

A lightweight, optionally typed expression language with a custom grammar for matching arbitrary Python objects.
https://zerosteiner.github.io/rule-engine/
BSD 3-Clause "New" or "Revised" License
445 stars 54 forks source link

String to Integer casting #9

Closed cah-rohithkarnati closed 3 years ago

cah-rohithkarnati commented 3 years ago

My required condition -> 'to_integer(some_column) > 180'

Unfortunately the I am receiving _sourcecolumn as a string data and do not want to put the casting logic in python directly in code. I am planning to put the conditions on the json where I am trying to store the condition and syphoning those from the code.

Please advise how I can implement the saem.

zeroSteiner commented 3 years ago

Version 2.3 added to_flt and to_int attributes for casting strings. Try some_column.to_int > 180, that should do the trick.

cah-rohithkarnati commented 3 years ago

Worked like a charms!!! Thanks. Great job though. Having fun using the lib. It would be great if you could point me towards the documentation, if any for these neat tricks.

zeroSteiner commented 3 years ago

Great, I'm glad that worked for you. Check out the Getting Started docs. There's quite abit of usage information in there.