-
-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
appending rows when there are dynamic columns #572
Comments
Thanks for the report, are you planning a pull request? |
no... (I would if i could) |
It would be great if you could test (or make test) the suggested patch above. |
#------short test ------
print(tablib.__version__)
data = tablib.Dataset()
txt='''Greg Thorton
Dave Coutts
Joshua Ourisman'''
data.extend([item.split() for item in txt.splitlines()])
def dynamicColumn(row):
return row[-1].upper()+'!'
data.append_col(dynamicColumn,'Calculated')
data.append(('Brad','Montgomery', dynamicColumn))
#----------result: as before, dynamicColumn is not evaluated:
# 3.5.0
# Greg |Thorton |THORTON!
# Dave |Coutts |COUTTS!
# Joshua|Ourisman |OURISMAN!
# Brad |Montgomery|<function dynamicColumn at 0x000001A071042940> |
Indeed, I worked on a similar but different use case in this patch. After adding a dynamic column, you can only provide the static values and the dynamic ones will be inserted automatically. The use case in your latest example is to be able to add a dynamic value in any row, regardless of any previous |
@hugovk do you think that adding dynamic values in rows is worth implementing? We could argue that when inserting rows, you should be able to compute the values yourself. |
I don't need it and am generally for less maintenance but not against it :) |
@LucOevel, I committed the current patch which matches this issue description. Now feel free to create a new ticket for adding support to appending rows including callable values. However, please describe also the use case for that functionality, as you could as well prepare the values you are going to insert before adding the row. |
As I understood it, the main point of dynamic columns is that their content automatically depends on other columns. So when other columns change, the dynamic values follow dynamically. Is that not what the name means? Having to pre-compute values when inserting a new row defeats that behavior, and those values will not be dynamic anymore. If the idea is that values can just as well be pre-computed instead of dynamic then why have dynamic values at all, right? BTW: @claudep can you provide an example of the use case you were thinking about? I seem to miss that point. |
At the moment we cannot add rows (using append, rpush, lpush) when there is already a dynamic column: a function object can be added at the appropriate place in the row, but unlike a normal dynamic column it will not be executed.
The text was updated successfully, but these errors were encountered: