-
-
Notifications
You must be signed in to change notification settings - Fork 593
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
Inserting column with insert_col fails if dataset contains 0 rows #583
Comments
To reproduce: >>> from tablib import Dataset
>>> ds = Dataset()
>>> ds.headers = ["First", "Second", "Third"]
>>> ds.insert_col(1, [], header="Insert")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/tablib/core.py", line 544, in insert_col
col = self._clean_col(col)
File "/usr/local/lib/python3.10/site-packages/tablib/core.py", line 372, in _clean_col
header = [col.pop(0)]
IndexError: pop from empty list |
Thanks for the report. See the patch I suggested to fix this issue. Please tell me what you think. |
Looks good to me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to add additional column to a Dataset that is created from a dictionary. I have headers defined separately. However, when dictionary is empty (no rows to export because how data is filtered)
insert_col
method fails with error:After looking in to the code of the method
_clean_col
, my guess, thatif
statement:tablib/src/tablib/core.py
Lines 373 to 376 in 4fd9a68
should be opposite:
or:
The text was updated successfully, but these errors were encountered: