Sci Parser
A parser design for extract data from the unstructured output of scientific software.
Installation
pip install sci-parser
Examples
Parse the output of Multiwfn
Sample: multiwfn-01.txt
from sci_parser.parser import Parser
from pprint import pprint
parser = (
Parser()
.kv_search('Total/Alpha/Beta electrons', v_type=float)
.kv_search('Net charge', v_type=float)
.kv_search('Expected multiplicity', v_type=int)
.kv_search('Atoms', stop_at=',', v_type=int)
.kv_search('Basis functions', stop_at=',', v_type=int)
.kv_search('GTFs', v_type=int)
.kv_search('Total energy', v_type=float)
.kv_search('Virial ratio', v_type=float)
.kv_search('Formula', value=r'(.*?) ')
.kv_search('Total atoms', v_type=int)
.kv_search('Molecule weight', v_type=float)
.kv_search('Atom list', multiline=True, stop_at='Note')
.kv_search('Molecular planarity parameter (MPP)', value=r'(.*)$', sep='is')
)
with open('tests/data/multiwfn-01.txt') as fp:
text = fp.read()
result = list(parser.parses(text))
pprint(result, width=120)
The output of the above code will be like the below
[('Total/Alpha/Beta electrons', 112.0),
('Net charge', 0.0),
('Expected multiplicity', 1),
('Atoms', 25),
('Basis functions', 293),
('GTFs', 517),
('Total energy', -992.117436714606),
('Virial ratio', 2.00276853),
('Formula', 'H11 C9 O4 P1'),
('Total atoms', 25),
('Molecule weight', 214.15535),
('Atom list',
'1(P ) --> Charge: 15.000000 x,y,z(Bohr): 0.178686 1.913277 0.237251\n'
' 2(O ) --> Charge: 8.000000 x,y,z(Bohr): -8.152243 -2.339458 1.431278\n'
' 3(C ) --> Charge: 6.000000 x,y,z(Bohr): -6.969052 -1.306063 -0.203009\n'
' 4(C ) --> Charge: 6.000000 x,y,z(Bohr): -4.964431 0.698255 0.252234\n'
' 5(C ) --> Charge: 6.000000 x,y,z(Bohr): -2.306306 -0.450518 -0.036829\n'
' 6(O ) --> Charge: 8.000000 x,y,z(Bohr): -0.017658 4.066113 -1.573236\n'
' 7(O ) --> Charge: 8.000000 x,y,z(Bohr): -0.156407 2.628518 3.220584\n'
' 8(C ) --> Charge: 6.000000 x,y,z(Bohr): 3.169999 0.255647 0.041310\n'
' 9(C ) --> Charge: 6.000000 x,y,z(Bohr): 3.926020 -1.429692 1.938584\n'
' 10(C ) --> Charge: 6.000000 x,y,z(Bohr): 6.205681 -2.721758 1.714089\n'
' 11(C ) --> Charge: 6.000000 x,y,z(Bohr): 7.736853 -2.337270 -0.398033\n'
' 12(C ) --> Charge: 6.000000 x,y,z(Bohr): 6.994777 -0.654194 -2.284029\n'
' 13(C ) --> Charge: 6.000000 x,y,z(Bohr): 4.714317 0.643294 -2.069900\n'
' 14(O ) --> Charge: 8.000000 x,y,z(Bohr): -7.323002 -1.977595 -2.656498\n'
' 15(H ) --> Charge: 1.000000 x,y,z(Bohr): -5.221096 1.420890 2.161586\n'
' 16(H ) --> Charge: 1.000000 x,y,z(Bohr): -5.203127 2.273013 -1.067921\n'
' 17(H ) --> Charge: 1.000000 x,y,z(Bohr): -2.048148 -1.321744 -1.894625\n'
' 18(H ) --> Charge: 1.000000 x,y,z(Bohr): -1.987820 -1.924367 1.374353\n'
' 19(H ) --> Charge: 1.000000 x,y,z(Bohr): 0.862508 4.044165 3.765548\n'
' 20(H ) --> Charge: 1.000000 x,y,z(Bohr): 2.750383 -1.710691 3.594765\n'
' 21(H ) --> Charge: 1.000000 x,y,z(Bohr): 6.791898 -4.021810 3.187218\n'
' 22(H ) --> Charge: 1.000000 x,y,z(Bohr): 9.513719 -3.346808 -0.568826\n'
' 23(H ) --> Charge: 1.000000 x,y,z(Bohr): 8.193501 -0.346968 -3.918830\n'
' 24(H ) --> Charge: 1.000000 x,y,z(Bohr): 4.131055 1.971614 -3.517319\n'
' 25(H ) --> Charge: 1.000000 x,y,z(Bohr): -6.315838 -0.943282 -3.778241\n'
' '),
('Molecular planarity parameter (MPP)', '1.109487 Angstrom')]
Metadata
Release files for sci-parser 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sci_parser-0.1.1.tar.gz | 3.9 kB | Without provenance | Details for sci_parser-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sci_parser-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for sci_parser-0.1.1-py3-none-any.whl |
Total release size: 8.3 kB
Release files / sci_parser-0.1.1.tar.gz
| Download URL | sci_parser-0.1.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3b2e0c78ad349d4a8169f35dc6744b2278821086554948aa917bd0c6237440f
|
|
BLAKE2b-256 checksum How to use checksums |
96f8750e66531aeebb9bde2d66627e587037f5675c8a61281fae89544163f93d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.12 Linux/5.15.153.1-microsoft-standard-WSL2
|
Release files / sci_parser-0.1.1-py3-none-any.whl
| Download URL | sci_parser-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb074934b8d84c19bcc1363f0851ff44785ba7168d737aef3dcaccd8d370a947
|
|
BLAKE2b-256 checksum How to use checksums |
1a1cf3cee00ce288c9a83e40dc08c3687d1a21443dfaa7ddbfe2d930baa8c2ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.12 Linux/5.15.153.1-microsoft-standard-WSL2
|
Security for sci-parser 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.