Closed Swarnitha-eluru closed 4 years ago
Hi @Swarnitha-eluru,
TBH I haven't completely understood your code but could you please try following this example:
https://github.com/frictionlessdata/tabulator-py#post-parse
You just need to replace the functions by greaterthan
and lessthan
I tried that is working,my problem was, here we are passing the skip_odd_rows ,multiply_by_two statistically. with Stream(rows, post_parse=[skip_odd_rows, multiply_by_two]) as stream: stream.read() I need to pass them dynamically That means I may get only this [skip_odd_rows] or only this [multiply_by_two] or both.I will get them in list as ["skip_odd_rows","multiply_by_two"] if i pass that to with Stream(rows, post_parse=["skip_odd_rows", "multiply_by_two"]) as stream: stream.read()
I am getting error as they are in string format which is not callable. Even though type of that was list. For overcoming that I tried to remove those double codes using python code Then I am getting like this [skip_odd_rows, multiply_by_two] But They are in string type.And I am getting the error as str is not callable My question was how to overcome this any solution to pass them dynamically. or what can i do to modify in the stream.py code from my end.As I have pulled the code from git.
@Swarnitha-eluru You just need to add them as functions:
post_parse=[]
if condition:
post_parse.append(skip_odd_rows)
if other_condition:
post_parse.append(multiply_by_two)
Maybe it's just simpler to have this logic not as post_parse
:
with Stream() as stream:
for row_number, headers, row in stream.iter(extended=True):
# filtering 1
# filtering 2
@roll thanks a lot my issue was solved. with this snippet test.zip
I am using postparse method to filter rows for the given source.I want to post parse two conditions suppose [greaterthan,lessthan] I will get them in this format ["greaterthan","lessthan"] I am removing the quotes through code and sending to post_parse=[greaterthan,lessthan] but they are in string format cant we send them as str? What can I do to allow even string format? My code was testing1.zip Error was:
Please help me on this.
I should pass dynamically into postparse.