Chemical formula parser
Project description
chemparse
Authors: Grayson Boyer and Victor Ignatenko
A lightweight package for parsing chemical formula strings into python dictionaries.
Features
- Convert a chemical formula string into a python dictionary.
- example:
"CH4"
returns{"C":1.0, "H":4.0}
- example:
- Handles fractional stoichiometry.
- example:
"C1.5O3"
returns{"C":1.5, "O":3.0}
- example:
"H2e-1O1e-1"
returns{"H":0.2, "O":0.1}
- example:
- Handles groups with parentheses.
- example:
"(CH3)2(CH2)4"
returns{"C":6.0, "H":14.0}
- example:
- New in 2024 Chemparse now handles nested paretheses!
- example:
"((CH3)2)3"
returns{'C': 6, 'H': 18}
- example:
Installation
Install chemparse
with pip:
$ pip install chemparse
Usage
Import chemparse in python and use the parse_formula function:
import chemparse
print(chemparse.parse_formula("C6H12O6"))
Contribute
Install python
Clone chemparse
using git:
git clone https://github.com/gmboyer/chemparse.git
Go to the chemparse
directory:
cd chemparse
Install requirements:
pip install -r requirements.txt
Now you are ready to contribute!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chemparse-0.2.0.tar.gz
(5.4 kB
view hashes)
Built Distribution
Close
Hashes for chemparse-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 110cdb1b930bc391a55861e1503c5a28ce4768fe1efc745d5519574a4cb588eb |
|
MD5 | 847222497a99b0613e91687970e4ba9c |
|
BLAKE2b-256 | 9aa3984a5722839bcae81ecc1a7424d4c0987a17143163f8b15a8bdf04030c23 |