Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

hotxlfp

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotxlfp

pipPyPI
Version
1.0.2
Maintainers
1

hotxlfp

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 -m unittest

Coverage

coverage run --source hotxlfp setup.py test

Update SUPPORTED_FORMULAS.md

Inside the project directory run:

python -m "scripts.update_supported_formulas"

Keywords

excel

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts