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

Bug report: Error when writing NaN #30

Closed
jkyeung opened this Issue Jul 3, 2013 · 8 comments

Comments

3 participants
@jkyeung
Contributor

jkyeung commented Jul 3, 2013

Due to float(x) being "not a number" when x.upper() == 'NAN', if such an x exists in the data being written, the resulting workbook will pop up a warning when opened in Excel:

Excel found unreadable content in 'foo.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.

Even assuming this warning isn't intimidating to the end user, and they go ahead and recover, the affected cell apparently becomes 'nan' (losing any capitalization).

Obviously this can be worked around by checking the data beforehand and using write_string(), but it's ugly and a pain, and it especially uglifies the calling code if the problem occurs in write_row().

Also, I don't know what the proper course of action is when a true numeric NaN shows up. (Perhaps somehow write #NUM! to the cell? That's the result of =0^0....)

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Jul 4, 2013

Owner

Hi John,

Could you post a small example that demonstrates the issue.

John.

Owner

jmcnamara commented Jul 4, 2013

Hi John,

Could you post a small example that demonstrates the issue.

John.

@jkyeung

This comment has been minimized.

Show comment
Hide comment
@jkyeung

jkyeung Jul 4, 2013

Contributor
from xlsxwriter.workbook import Workbook

wb = Workbook('foo.xlsx')
ws = wb.add_worksheet()
ws.write(0, 0, 'Nan')
wb.close()

popup1

Contributor

jkyeung commented Jul 4, 2013

from xlsxwriter.workbook import Workbook

wb = Workbook('foo.xlsx')
ws = wb.add_worksheet()
ws.write(0, 0, 'Nan')
wb.close()

popup1

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Jul 4, 2013

Owner

And you expect 'Nan' to be handled as a string. Is that correct?

Owner

jmcnamara commented Jul 4, 2013

And you expect 'Nan' to be handled as a string. Is that correct?

@jkyeung

This comment has been minimized.

Show comment
Hide comment
@jkyeung

jkyeung Jul 5, 2013

Contributor

Correct.

But even folks who expect it to be handled as float('Nan') should not have to deal with Excel complaining about "unreadable content". If you think it fits XlsxWriter's philosophy better to write #NUM!, I would go with that.

Contributor

jkyeung commented Jul 5, 2013

Correct.

But even folks who expect it to be handled as float('Nan') should not have to deal with Excel complaining about "unreadable content". If you think it fits XlsxWriter's philosophy better to write #NUM!, I would go with that.

@ghost ghost assigned jmcnamara Jul 22, 2013

@jmcnamara jmcnamara closed this in 164f629 Jul 24, 2013

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Jul 24, 2013

Owner

On your second point: A float('NAN') is now a TypeError exception in write_number().

If this proves to be an issue for people then I'll look into adding Excel error types.

Owner

jmcnamara commented Jul 24, 2013

On your second point: A float('NAN') is now a TypeError exception in write_number().

If this proves to be an issue for people then I'll look into adding Excel error types.

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Jul 24, 2013

Owner

P.S. John. please keep submitting bugs as you find them but can you submit them in the form of a program. That way it is easier to convert to a test case and then fix.

See also Issue 1 for details.

Thanks,

John

Owner

jmcnamara commented Jul 24, 2013

P.S. John. please keep submitting bugs as you find them but can you submit them in the form of a program. That way it is easier to convert to a test case and then fix.

See also Issue 1 for details.

Thanks,

John

@eudoxos

This comment has been minimized.

Show comment
Hide comment
@eudoxos

eudoxos Jul 30, 2014

Hi, this handling of NaN/Inf is an issue for me (and incompatibility with xlwt, which used to happily write #NUM!). Is there some workaround?

eudoxos commented Jul 30, 2014

Hi, this handling of NaN/Inf is an issue for me (and incompatibility with xlwt, which used to happily write #NUM!). Is there some workaround?

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Jul 30, 2014

Owner

@eudoxos

This issue is closed so It would be best to open a new issue.

Please include a sample program that demonstrates the issue.

John

Owner

jmcnamara commented Jul 30, 2014

@eudoxos

This issue is closed so It would be best to open a new issue.

Please include a sample program that demonstrates the issue.

John

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment