Chemical formula parser
Project description
chemparse
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}
- Note: chemparse currently only handles non-nested paretheses. A formula with nested parentheses like
"CH3(C2(CH3)2)3CH3"
will not work properly.
- 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"))
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.1.1.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for chemparse-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05a63076ffe7546dde6c4c5a81934e8f38181f8f9fac9cd47c84b85f5459caaf |
|
MD5 | fe3850a71a14bd41be9d61f9f954cb7d |
|
BLAKE2b-256 | 45481d6f064a335a666e368e85b404831760131911aaa2b9af7a4b7aa351b2fa |