Skip to main content

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}
  • Handles fractional stoichiometry.
    • example: "C1.5O3" returns {"C":1.5, "O":3.0}
    • example: "H2e-1O1e-1" returns {"H":0.2, "O":0.1}
  • 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.

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


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.2.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chemparse-0.1.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file chemparse-0.1.2.tar.gz.

File metadata

  • Download URL: chemparse-0.1.2.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.26.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.11

File hashes

Hashes for chemparse-0.1.2.tar.gz
Algorithm Hash digest
SHA256 09ebfb37b31350f2a9db9914ebb7944ef00443dc3900684b056621f7189e9afb
MD5 97e2d668194b121114971e78ec3dc6d1
BLAKE2b-256 3871416460fe4d279090ac25aae3b282409f8578a38d7a6bd90505328230d65a

See more details on using hashes here.

File details

Details for the file chemparse-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: chemparse-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.26.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.11

File hashes

Hashes for chemparse-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 151d84816c8f3e984b3e5fdbaac3664675ca0b24b7d8543be101a72931fa71c6
MD5 bef1ebb85b7d335d62cd4920a9262461
BLAKE2b-256 9133063ccc672aa175c386fb6355765f191f8c08045b52a08dc0f1c477300b94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page