in2csv error message with provided XLS on Python 2
Created by: giovanma
I have an .xls file with two sheets and I wanted to create two .csv files (one per sheet). I type in2csv --write-sheets "-" test.xls in the command line and I obtain the following output:
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 2 has no name. Using "c".
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 3 has no name. Using "d".
/usr/local/lib/python2.7/site-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "ESTIMATED PARAMS" already exists in Table. Column will be renamed to "ESTIMATED PARAMS_2".
**,ESTIMATED PARAMS,c,d,ESTIMATED PARAMS_2
,,,,
,,,,
,EPS_GAPOILTREND_RoW,,,EPS_GAPOILTREND_RoW
Traceback (most recent call last):
File "/usr/local/bin/in2csv", line 11, in <module>
load_entry_point('csvkit==1.0.3', 'console_scripts', 'in2csv')()
File "/usr/local/lib/python2.7/site-packages/csvkit/utilities/in2csv.py", line 182, in launch_new_instance
utility.run()
File "/usr/local/lib/python2.7/site-packages/csvkit/cli.py", line 118, in run
self.main()
File "/usr/local/lib/python2.7/site-packages/csvkit/utilities/in2csv.py", line 165, in main
tables = agate.Table.from_xls(self.input_file, sheet=sheets, **kwargs)
File "/usr/local/lib/python2.7/site-packages/agateexcel/table_xls.py", line 33, in from_xls
book = xlrd.open_workbook(file_contents=path.read(), encoding_override=encoding_override)
File "/usr/local/lib/python2.7/site-packages/xlrd/__init__.py", line 116, in open_workbook
with open(filename, "rb") as f:
TypeError: coercing to Unicode: need string or buffer, NoneType found
coercing to Unicode: need string or buffer, NoneType found
If I transform the xls file into xlsx file and I type in2csv --write-sheets "-" test.xlsx
then everything works properly, and I obtain the following output:
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 2 has no name. Using "c".
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 3 has no name. Using "d".
/usr/local/lib/python2.7/site-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "ESTIMATED PARAMS" already exists in Table. Column will be renamed to "ESTIMATED PARAMS_2".
**,ESTIMATED PARAMS,c,d,ESTIMATED PARAMS_2
,,,,
,,,,
,EPS_GAPOILTREND_RoW,,,EPS_GAPOILTREND_RoW
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 2 has no name. Using "c".
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 3 has no name. Using "d".
/usr/local/lib/python2.7/site-packages/agate/utils.py:292: DuplicateColumnWarning: Column name "ESTIMATED PARAMS" already exists in Table. Column will be renamed to "ESTIMATED PARAMS_2".
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 0 has no name. Using "a".
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 1 has no name. Using "b".
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 2 has no name. Using "c".
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 3 has no name. Using "d".
/usr/local/lib/python2.7/site-packages/agate/utils.py:276: UnnamedColumnWarning: Column 4 has no name. Using "e".
Since I am interested in .xls files I would like to know if it was possible to have the --write-sheets "-" option to work properly with .xls files.
I attach a zip file with both the xls and xlsx files I used.
Python 2.7.14 macOS 10.13.4 Thanks,