Code Monkey home page Code Monkey logo

hotxlfp's Introduction

hotxlfp

Build Status codecov

hotxlfp intends to be a python version of the javascript handsontable excel formula parser differences are acceptable to make it more pythonic or the function implementations more correct.

Install

You can install using pip

pip install hotxlfp

Usage

Create a Parser

import hotxlfp
p = hotxlfp.Parser()

Parse excel formulas

p.parse('SUM(1,2,3)') # returns {'result': 6, 'error': None}

It's also fine to use semi-colons as separators (they're used by excel depending on your locale)

p.parse('SUM(1;2;3)') # returns {'result': 6, 'error': None}

Custom functions

Say you have a function called triple:

def triple(x):
    return x*3

You can teach the parser to use it with set_function

p.set_function('TRIPLE', triple)
p.parse('TRIPLE(2)') # returns {'result': 6, 'error': None}

Variables

You can also set variables that you can then use in your formulas

p.set_variable('foo', 33)
p.parse('foo/3') # returns {'result': 11.0, 'error': None}

Contributing

Fork the project

Installing Dependencies

Depends on ply and python-dateutil.

To install dependencies automatically using pip run:

pip install -r requirements.txt

Testing

python setup.py test

Coverage

coverage run --source hotxlfp setup.py test

Update SUPPORTED_FORMULAS.md

Inside the project directory run:

python -m "scripts.update_supported_formulas"

hotxlfp's People

Contributors

leonelcamara avatar

Watchers

James Cloos avatar

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.