Coder Social home page Coder Social logo

azaitsev / millify Goto Github PK

View Code? Open in Web Editor NEW
83.0 83.0 12.0 6 KB

Convert long numbers into a human-readable format in Python

License: MIT License

Python 100.00%
big-number human-readable human-readable-representations number-formatter numbers-to-text

millify's People

Contributors

azaitsev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

millify's Issues

999999 returns 1000k

Using 999999 with millify should return 1M but it returns 1000k

>>> from millify import millify
>>> millify('999999')
>>> '1000k'

Format to a fixed number of characters would be a nice addition

Sometimes you want a fixed number of characters to be used for a number (for logging for example).

With 5 characters (this includes numbers, decimal points and magnitude):

4000000 => 4.00M
40000   => 40.0K
4000    => 4.00K
400     => 0.40K (400 and 400.0 are wrong as they take 3 and 5 places)
40      => 0.04K or 40.00
4       => 4.000

Code error on prettify function

The function prettify has a self-loop, but it doesn't account for a different character in the loop it just affects the first iteration.
This is the solution to the error.

def prettify(amount, separator=','): """Separate with predefined separator.""" orig = str(amount) new = re.sub("^(-?\d+)(\d{3})", "\g<1>{0}\g<2>".format(separator), str(amount)) if orig == new: return new else: return prettify(new, separator)

This Library works!!

Notice issued in public interest

  • The library hasn't been updated from 7 years because it doesn't need to be updated
  • This library just works!

Reverse the library

Could you make a reversed version of your library? One that converts shortened prefixes to their longer number counterparts.

That would be amazing. Thanks for the project as well.

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.