You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If headers are defined in a Dataset it would be helpful to allow element access within a row of the Dataset by column label in addition to index based access. Issue #22 suggested using namedtuples for this but --while acknowledging the general usefulness of such a feature-- was discarded because namedtuples would not support append, etc.
Implementing this via OrderedDicts should be possible though. It would require (it seems only in tablib/core.py on a first pass):
Row constructor to accept an additional headers argument
_set_headers to be augmented to update existing rows with new column labels
Changes to Row methods insert, __getitem__, __setitem__, and updates/changes to a few other special methods in Dataset and Row
It would introduce some overhead but given that Tablib is aimed at use cases "below" the Pandas level that might be acceptable and should not break the API.
I'm happy to give this a shot but --given that it will require changes in quite a few places in core.py-- would appreciate some feedback if (a) people still think that this would indeed be useful and (b) anyone sees a reason why doing this as outlined above is not a good idea (or may not even work at all...).
Many thanks!
The text was updated successfully, but these errors were encountered:
Actually, OrderedDict is probably overkill... can simply keep reference to the Dataset that created/owns Row instance in that instance to have access to headers from within the Row instance...
If headers are defined in a Dataset it would be helpful to allow element access within a row of the Dataset by column label in addition to index based access. Issue #22 suggested using namedtuples for this but --while acknowledging the general usefulness of such a feature-- was discarded because namedtuples would not support append, etc.
Implementing this via OrderedDicts should be possible though. It would require (it seems only in tablib/core.py on a first pass):
headers
argument_set_headers
to be augmented to update existing rows with new column labelsinsert
,__getitem__
,__setitem__
, and updates/changes to a few other special methods in Dataset and RowIt would introduce some overhead but given that Tablib is aimed at use cases "below" the Pandas level that might be acceptable and should not break the API.
I'm happy to give this a shot but --given that it will require changes in quite a few places in
core.py
-- would appreciate some feedback if (a) people still think that this would indeed be useful and (b) anyone sees a reason why doing this as outlined above is not a good idea (or may not even work at all...).Many thanks!
The text was updated successfully, but these errors were encountered: