# hotxlfp
hotxlfp intends to be a python version of the javascript [handsontable excel formula parser](https://github.com/handsontable/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"
Raw data
{
"_id": null,
"home_page": "https://github.com/aidhound/hotxlfp",
"name": "hotxlfp",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "excel, formula, parser",
"author": "Leonel C\u00e2mara",
"author_email": "leonelcamara@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8e/60/11c5888ba7c0ce003ffc91dd2ef4834e73c3846fd79b7bb8653f774ab4c3/hotxlfp-1.0.2.tar.gz",
"platform": null,
"description": "# hotxlfp\r\n\r\n\r\n\r\n\r\n\r\nhotxlfp intends to be a python version of the javascript [handsontable excel formula parser](https://github.com/handsontable/formula-parser) differences are acceptable to make it more pythonic or the function implementations more correct.\r\n\r\n\r\n\r\n# Install\r\n\r\n\r\n\r\nYou can install using pip\r\n\r\n\r\n\r\n pip install hotxlfp\r\n\r\n\r\n\r\n# Usage\r\n\r\n\r\n\r\n## Create a Parser\r\n\r\n\r\n\r\n import hotxlfp\r\n\r\n p = hotxlfp.Parser()\r\n\r\n\r\n\r\n## Parse excel formulas \r\n\r\n\r\n\r\n p.parse('SUM(1,2,3)') # returns {'result': 6, 'error': None}\r\n\r\n\r\n\r\nIt's also fine to use semi-colons as separators (they're used by excel depending on your locale)\r\n\r\n\r\n\r\n p.parse('SUM(1;2;3)') # returns {'result': 6, 'error': None}\r\n\r\n\r\n\r\n## Custom functions\r\n\r\n\r\n\r\nSay you have a function called triple:\r\n\r\n\r\n\r\n def triple(x):\r\n\r\n return x*3\r\n\r\n\r\n\r\nYou can teach the parser to use it with set_function\r\n\r\n\r\n\r\n p.set_function('TRIPLE', triple)\r\n\r\n p.parse('TRIPLE(2)') # returns {'result': 6, 'error': None}\r\n\r\n\r\n\r\n## Variables\r\n\r\n\r\n\r\nYou can also set variables that you can then use in your formulas\r\n\r\n\r\n\r\n p.set_variable('foo', 33)\r\n\r\n p.parse('foo/3') # returns {'result': 11.0, 'error': None}\r\n\r\n\r\n\r\n# Contributing\r\n\r\n\r\n\r\nFork the project\r\n\r\n\r\n\r\n## Installing Dependencies \r\n\r\n \r\n\r\nDepends on ply and python-dateutil. \r\n\r\n \r\n\r\nTo install dependencies automatically using pip run:\r\n\r\n\r\n\r\n pip install -r requirements.txt\r\n\r\n \r\n\r\n## Testing \r\n\r\n\r\n\r\n python -m unittest\r\n\r\n\r\n\r\n## Coverage\r\n\r\n\r\n\r\n coverage run --source hotxlfp setup.py test\r\n\r\n\r\n\r\n## Update SUPPORTED_FORMULAS.md\r\n\r\n\r\n\r\nInside the project directory run:\r\n\r\n\r\n\r\n python -m \"scripts.update_supported_formulas\"\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": null,
"version": "1.0.2",
"project_urls": {
"Download": "https://github.com/aidhound/hotxlfp/archive/1.0.2.tar.gz",
"Homepage": "https://github.com/aidhound/hotxlfp"
},
"split_keywords": [
"excel",
" formula",
" parser"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9cfe16cf415ceb485bf9f23bdbdd3e7b181c7147f82bcfde3c3bb55a14e8461f",
"md5": "0a72eefacfbe257703c2ed96bfd3f4c0",
"sha256": "c6befebac83b9e015ad4335fb1cdaf7cb7953567a5e2c1b17aa14d0d71fa5828"
},
"downloads": -1,
"filename": "hotxlfp-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0a72eefacfbe257703c2ed96bfd3f4c0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 40293,
"upload_time": "2024-12-03T15:33:03",
"upload_time_iso_8601": "2024-12-03T15:33:03.490899Z",
"url": "https://files.pythonhosted.org/packages/9c/fe/16cf415ceb485bf9f23bdbdd3e7b181c7147f82bcfde3c3bb55a14e8461f/hotxlfp-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8e6011c5888ba7c0ce003ffc91dd2ef4834e73c3846fd79b7bb8653f774ab4c3",
"md5": "eeb737bb63b2752c50054fb494c84e75",
"sha256": "82efa4364b1960da5ff139f6ea5dbc0771c7c24604b201f55a160ed96239574e"
},
"downloads": -1,
"filename": "hotxlfp-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "eeb737bb63b2752c50054fb494c84e75",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 35879,
"upload_time": "2024-12-03T15:33:05",
"upload_time_iso_8601": "2024-12-03T15:33:05.064317Z",
"url": "https://files.pythonhosted.org/packages/8e/60/11c5888ba7c0ce003ffc91dd2ef4834e73c3846fd79b7bb8653f774ab4c3/hotxlfp-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-03 15:33:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aidhound",
"github_project": "hotxlfp",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"requirements": [],
"lcname": "hotxlfp"
}