Closed aishjain closed 4 years ago
Yeah the documentation could probably use some elaboration :sweat_smile: . It's kinda tough to describe how to use it, because it's abstract. You have a one or more "things" in Python that follow a structure like a list of people described as dictionaries, books described by objects, etc. and you can filter them using a rule defined by either you or the end user. That last part's important, rules are intended to be safely written by the end user without any kinds of injection flaws that might come up from doing something like eval
or exec
.
Take a look at the examples/
directory while I look at adding more documentation. The csv_filter and github_filter are probably the two most simple ones. For the CSV one, you can simply load a CSV file that has column names as the first row, and then apply filters on to the rows. Keep in mind though that all data is treated as strings though, so you can't do integer comparison in this particular usage.
I hope that helps you get started, it might be a few days until I can really write some more docs.
Thank you for the quick reply, I tried running the csv_filter.py file, I end up getting errors: usage: csv_filter.py [-h] csv_file rule csv_filter.py: error: the following arguments are required: csv_file, rule
D:\IoT\rule-engine-master\rule-engine-master\examples>python csv_filter.py new.csv rule
Traceback (most recent call last):
File "csv_filter.py", line 81, in
Basically I am not understanding what is meant by passing the argument called rule, what exactly is expected here.?and can you please provide a sample CSV file that can be used here? It might be a very basic question, but it would be a great help for me in understanding your work. Thank ypu!
That's saying that the symbol rule
is not defined in your CSV file. That example expects that the first row is the name of each of the vars. If you're familiar with say Star Wars, you might have a CSV file to describe the characters like this:
test.csv:
firstName,lastName,affiliation,alive
Luke,Skywalker,Jedi,true
Darth,Vader,Sith,false
Han,Solo,Rebel Alliance,true
You could then query that CSV file to find characters that are alive with alive == 'true'
, or characters that are rebels with affiliation == 'Rebel Alliance'
as the rule. Notice that in this case alive
and affiliation
are symbols defined in our CSV file and that are are strings (i.e. alive
is not a boolean, we'd need to load a JSON file for that).
Hi, I am just beginning with rule engines, honestly, it's the first time I am coming across it, I see you have added examples in the repository but can you please elaborate the readme file on how to use them and what do they actually do?It would be really helpful for beginners like me. And sorry for putting it up as an issue, didn't know where else to ask you for the help. Thank you!