petl-developers / petl

Python Extract Transform and Load Tables of Data
MIT License
1.25k stars 193 forks source link

`convertall` does not work when table header has non-string elements #579

Closed dnicolodi closed 2 years ago

dnicolodi commented 2 years ago

Minimal, reproducible code sample, a copy-pastable example if possible

t = [['foo', 11, 22], [2, 2, 2]]
petl.convertall(t, lambda x: x**2)

Problem description

convertall() uses head() to access the field names, but this returns the header as is and the filed names are not usable if they are not strings. I think it should be using fieldnames() instead. The same bug affects other functions implemented on top of convertall().

Version and installation information

This is observed with petl 1.7.4 but the current git head contains the same implementation of convertall().