xlsx2csv icon indicating copy to clipboard operation
xlsx2csv copied to clipboard

Getting Error - xlsx2csv 0.7.3 with Python 2.7

Open StephenDcruz opened this issue 7 years ago • 8 comments

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 import('pkg_resources').run_script('xlsx2csv==0.7.3', 'xlsx2csv') File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 742, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 1510, in run_script exec(script_code, namespace, namespace) File "/usr/local/lib/python2.7/site-packages/xlsx2csv-0.7.3-py2.7.egg/EGG-INFO/scripts/xlsx2csv", line 963, 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

StephenDcruz avatar Jan 18 '18 21:01 StephenDcruz

On a very basic sample file, it works. To further investigate, we need you to provide your test file.

setop avatar Jan 24 '18 08:01 setop

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 .

StephenDcruz avatar Jan 25 '18 20:01 StephenDcruz

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.

  1. xlsx2csv test.xlsx -a Sheet 6 not found // Note first sheet has id = 6

  2. xlsx2csv test.xlsx -n 'Sheet3' Sheet 8 no found // Note the third sheet is named Sheet3 and id = 8

  3. xlsx2csv test.xlsx -s 3 > test.csv TypeError: %d format: a number is required, not NoneType

Can you please help?

StephenDcruz avatar Feb 02 '18 19:02 StephenDcruz

Hi, as setop already wrote, we need a test file. It seems like file contains some unsupported data format.

dilshod avatar Feb 02 '18 19:02 dilshod

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.

StephenDcruz avatar Feb 02 '18 20:02 StephenDcruz

@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

stianlik avatar Apr 01 '19 20:04 stianlik

I've fixed it and pushed with the last commit

dilshod avatar Apr 04 '19 05:04 dilshod

That's great, thanks!

stianlik avatar Apr 14 '19 07:04 stianlik