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
In my usecase, my "rowgenerator" helper function function do need a named tuple and not a plain row as an input. This is a great convenience to call named attribute instead of unclear row[5] - "index notation".
For that purpose I tried to use rowmapmany in this way :
I thought that using namedtuples will solve my issue (because my row has more than 100 columns, so it is a bit hard to use indexes i.e row[57] where a named tuple could simply gives me the convenience of row.my_target_attribute.
But because of this conversion to Record instance, the input will convert each namedtuple to a plain list of values which is a bit frustrating, since it forces us to use the indexes notation in the mapper function (very hard to read).
Another reason to not convert to a Record : using nameduple as input for the rowmapper, unleash us from any order binding... accessing property in the mapper will be by name and not by position.
So no matter what are the order of the field in the input source, the mapper will work as expected, even if the field order changed between two input that have the same output target.
In this method :
petl/petl/transform/maps.py
Line 309 in 0be2735
Each row is converted to a
Record
instance.petl/petl/transform/maps.py
Line 314 in 0be2735
In my usecase, my "rowgenerator" helper function function do need a named tuple and not a plain row as an input. This is a great convenience to call named attribute instead of unclear
row[5]
- "index notation".For that purpose I tried to use
rowmapmany
in this way :I thought that using
namedtuples
will solve my issue (because my row has more than 100 columns, so it is a bit hard to use indexes i.erow[57]
where a named tuple could simply gives me the convenience ofrow.my_target_attribute
.But because of this conversion to Record instance, the input will convert each namedtuple to a plain list of values which is a bit frustrating, since it forces us to use the indexes notation in the mapper function (very hard to read).
When I remove this line
petl/petl/transform/maps.py
Line 314 in 0be2735
It works like a charm....
Why this Record conversion is important ?
If it is not, could we remove it from the
iterrowmapmany
method ?Please help 🙏
The text was updated successfully, but these errors were encountered: