xlsx2csv icon indicating copy to clipboard operation
xlsx2csv copied to clipboard

NameError: global name 'eprint' is not defined

Open Achillefs opened this issue 5 years ago • 9 comments

Hey, we are using xlsx2csv to import sheets and it generally works fine. Recently, while trying to upload a specific sheet we got the following error:

File "/home/rof/.pyenv/versions/2.7.16/bin/xlsx2csv", line 817, in handleCharData
     eprint("Error: potential invalid date format.")
 NameError: global name 'eprint' is not defined

We moved the eprint method at the top of the file, and the script worked with only a warning as I assume was intended, but I am not sure if that is a correct solution?

thanks ac

Achillefs avatar May 08 '19 17:05 Achillefs

same issue:

Traceback (most recent call last):
  File "/usr/bin/xlsx2csv", line 803, in handleCharData
    self.data = ("%f" % (float(self.data))).rstrip('0').rstrip('.')
ValueError: could not convert string to float: '#N/A'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/xlsx2csv", line 1129, in <module>
    xlsx2csv.convert(outfile, sheetid)
  File "/usr/bin/xlsx2csv", line 258, in convert
    self._convert(s['index'], of)
  File "/usr/bin/xlsx2csv", line 318, in _convert
    sheet.to_csv(writer)
  File "/usr/bin/xlsx2csv", line 732, in to_csv
    self.parser.ParseFile(self.filehandle)
  File "/usr/src/ports/python35/python35-3.5.7-1.x86_64/src/Python-3.5.7/Modules/pyexpat.c", line 282, in CharacterData
  File "/usr/bin/xlsx2csv", line 817, in handleCharData
    eprint("Error: potential invalid date format.")
NameError: name 'eprint' is not defined
$ xlsx2csv --version
0.7.6

thanks,

naokikambe avatar Aug 09 '19 02:08 naokikambe

Hi there,

same issue here :/

Traceback (most recent call last):
  File "/usr/bin/xlsx2csv", line 803, in handleCharData
    self.data = ("%f" % (float(self.data))).rstrip('0').rstrip('.')
ValueError: could not convert string to float: '#N/A'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/xlsx2csv", line 1129, in <module>
    xlsx2csv.convert(outfile, sheetid)
  File "/usr/bin/xlsx2csv", line 216, in convert
    self._convert(sheetid, outfile)
  File "/usr/bin/xlsx2csv", line 318, in _convert
    sheet.to_csv(writer)
  File "/usr/bin/xlsx2csv", line 732, in to_csv
    self.parser.ParseFile(self.filehandle)
  File "../Modules/pyexpat.c", line 272, in CharacterData
  File "/usr/bin/xlsx2csv", line 817, in handleCharData
    eprint("Error: potential invalid date format.")
NameError: name 'eprint' is not defined
xlsx2csv --version
0.7.5

andb0t avatar Mar 29 '21 14:03 andb0t

Can someone send me a sample file to reproduce this?

dilshod avatar Apr 05 '21 10:04 dilshod

Sure, I created a minimal example with one cell filled only. It seems to be connected (in my case at least) with the formatting of the cell.

> xlsx2csv Book1.xlsx
Traceback (most recent call last):
  File "/usr/bin/xlsx2csv", line 803, in handleCharData
    self.data = ("%f" % (float(self.data))).rstrip('0').rstrip('.')
ValueError: could not convert string to float: '#N/A'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/xlsx2csv", line 1129, in <module>
    xlsx2csv.convert(outfile, sheetid)
  File "/usr/bin/xlsx2csv", line 216, in convert
    self._convert(sheetid, outfile)
  File "/usr/bin/xlsx2csv", line 318, in _convert
    sheet.to_csv(writer)
  File "/usr/bin/xlsx2csv", line 732, in to_csv
    self.parser.ParseFile(self.filehandle)
  File "../Modules/pyexpat.c", line 272, in CharacterData
  File "/usr/bin/xlsx2csv", line 817, in handleCharData
    eprint("Error: potential invalid date format.")
NameError: name 'eprint' is not defined

Here is the file: Book1.xlsx

andb0t avatar Apr 19 '21 16:04 andb0t

Hm, I'm getting:

./xlsx2csv.py ~/Downloads/Book1.xlsx Error: potential invalid date format. #N/A

On boh python 2 and 3. What version of xlsx2csv are you using?

dilshod avatar Apr 19 '21 17:04 dilshod

xlsx2csv --version
0.7.5

This one!

andb0t avatar Apr 19 '21 17:04 andb0t

You're using the .py version, I'm using the binary installed via apt install xlsx2csv. Does that make a difference?

andb0t avatar Apr 19 '21 17:04 andb0t

It seems it does. I don't know how apt version is uploaded, I'm uploading only pypy version.

dilshod avatar Apr 19 '21 17:04 dilshod

I am also facing similar issue. xlsx2csv version 0.7.5. Anybody have any solution for this? Please suggest.

Traceback (most recent call last):
  File "/usr/bin/xlsx2csv", line 803, in handleCharData
    self.data = ("%f" % (float(self.data))).rstrip('0').rstrip('.')
ValueError: could not convert string to float: '#N/A'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/xlsx2csv", line 1129, in <module>
    xlsx2csv.convert(outfile, sheetid)
  File "/usr/bin/xlsx2csv", line 216, in convert
    self._convert(sheetid, outfile)
  File "/usr/bin/xlsx2csv", line 318, in _convert
    sheet.to_csv(writer)
  File "/usr/bin/xlsx2csv", line 732, in to_csv
    self.parser.ParseFile(self.filehandle)
  File "../Modules/pyexpat.c", line 272, in CharacterData
  File "/usr/bin/xlsx2csv", line 817, in handleCharData
    eprint("Error: potential invalid date format.")
NameError: name 'eprint' is not defined

RorDevAlt avatar Mar 15 '22 04:03 RorDevAlt