Code Monkey home page Code Monkey logo

Comments (6)

peloriante avatar peloriante commented on May 31, 2024 1

Great point @bayesianmind

Merged your suggestion in b0ff639

from perfi.

bayesianmind avatar bayesianmind commented on May 31, 2024

Turns out this is a very old long-standing bug in openpyxl and the fix is to use an alternate library or apply a patch: https://stackoverflow.com/questions/13637888/openpyxl-please-do-not-assume-text-as-a-number-when-importing

from perfi.

lhl avatar lhl commented on May 31, 2024

Thanks for chasing that down, will sit down soon and figure the best way to triage. We already use xlsxwriter since it does a better job on writing our export, could look into pylightxl vs openpyxl for reading I guess? https://www.python-excel.org/

Or it might be easier to add a case to look for scientific notation and just have decimal_from_str handle it. @peloriante

from perfi.

bayesianmind avatar bayesianmind commented on May 31, 2024

I tried pylightxl and it does the exact same behavior unfortunately.
Both seem to be keeping the precision, so likely the solution here is having decimal_from_str understand scientific notation.

from perfi.

peloriante avatar peloriante commented on May 31, 2024

Thanks for this report, @bayesianmind! I made a small change (See fd63f28) to just float the str inside decimal_from_str before we cast to Decimal. I think this will handle parsing out any scientific notation present in the value.

Can you get latest and try again?

from perfi.

bayesianmind avatar bayesianmind commented on May 31, 2024

Thanks @peloriante!
It would be best to keep precision, especially given how huge some units can be. I tested your patch on my import and was seeing sizable rounding errors, especially for BTC where 1 unit is so expensive.
I put a comment on fd63f28 suggesting a better implementation that preserves all precision.

from perfi.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.