petl-developers / petl

Python Extract Transform and Load Tables of Data
MIT License
1.22k stars 190 forks source link

Fix todataframe() to do not iterate the table multiple times #581

Closed dnicolodi closed 2 years ago

dnicolodi commented 2 years ago

Converting the table data to a list simply with list() causes the table to be materialized three times because list() calls len() on the table twice to populate the list.

Anyhow, there is no need to have the table data in a list when an iteratotor can be passed to pandas.DataFrame.from_records().

Fixes #578.

coveralls commented 2 years ago

Coverage Status

Coverage remained the same at 91.12% when pulling cbae170095cd3832d08407fca67203ee532febf2 on dnicolodi:todataframe-fix into 33f732831507d11da2264b5c57122c3c6612efd4 on petl-developers:master.