xlsx2csv
xlsx2csv copied to clipboard
Getting Error - xlsx2csv 0.7.3 with Python 2.7
Hi,
I am getting the following error when I use xlsx2csv to convert xlsx file to csv. The xlsx file has around 85,000 records. Please help.
$ xlsx2csv Test.xlsx -s 1 -f "%Y-%m-%d" > test.csv
Traceback (most recent call last):
File "/usr/local/bin/xlsx2csv", line 4, in
File "/usr/local/lib/python2.7/site-packages/xlsx2csv-0.7.3-py2.7.egg/EGG-INFO/scripts/xlsx2csv", line 192, in convert
File "/usr/local/lib/python2.7/site-packages/xlsx2csv-0.7.3-py2.7.egg/EGG-INFO/scripts/xlsx2csv", line 270, in _convert
File "/usr/local/lib/python2.7/site-packages/xlsx2csv-0.7.3-py2.7.egg/EGG-INFO/scripts/xlsx2csv", line 609, in to_csv
File "/usr/local/lib/python2.7/site-packages/xlsx2csv-0.7.3-py2.7.egg/EGG-INFO/scripts/xlsx2csv", line 631, in handleCharData
TypeError: %d format: a number is required, not NoneType
On a very basic sample file, it works. To further investigate, we need you to provide your test file.
Hi,
Thank you for the response.
Unfortunately I cannot provide the file which is confidential.
But here is what I have found. We get an xlsx file from our client that has 3 worksheets. I am trying to convert the 3rd one which has few blank rows and summary at the top and the actual header starts at line 14.I am transferring this file to a linux machine and trying to convert it to csv using xlsx2csv.
So if I convert this file as is, it throws an error which I mentioned before. However, if I open the file in my system and save it again without changing anything, transfer to linux and then run xlsx2csv - it works. This makes me think further in terms of the excel environment. The client is having latest version of excel whereas I have excel 2007. When I save the file in my local environment, it saves as xlsx 2007. Further I tried to open that file in office 365 and saved it.It worked too.
I am not sure whether this has to do with the version of excel, but just wanted to let you know.
Thanks again.
On Wed, Jan 24, 2018 at 2:13 PM, setop [email protected] wrote:
On a very basic sample file, it works. To further investigate, we need you to provide your test file.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dilshod/xlsx2csv/issues/133#issuecomment-360060016, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah7mg0MzioQKc5-HY6DrjJFCnIKIgFY_ks5tNu09gaJpZM4RjkFF .
I have found another clue on this.
As I said previously, the input excel file consist of 3 sheets. Here is what it makes it different from other input file. The three sheets have sheet ids as 6, 7, 8 and not 1, 2, 3. This makes the code break if I give the following command.
-
xlsx2csv test.xlsx -a Sheet 6 not found // Note first sheet has id = 6
-
xlsx2csv test.xlsx -n 'Sheet3' Sheet 8 no found // Note the third sheet is named Sheet3 and id = 8
-
xlsx2csv test.xlsx -s 3 > test.csv TypeError: %d format: a number is required, not NoneType
Can you please help?
Hi, as setop already wrote, we need a test file. It seems like file contains some unsupported data format.
Thanks for the quick response.
Sorry I cannot create a test file for this. Neither I can send the original file. I need to debug this further.
@dilshod I have the same issue and can give you an example file. See input-weird.xlsx. The content looks meaningless because I removed most rows before uploading.
xlsx2csv -v
0.7.3
xlsx2csv -a input-weird.xlsx
-------- 6 - Sheet1
Sheet 6 not found
I've fixed it and pushed with the last commit
That's great, thanks!