<div align="center">
<a align="center" href="https://pypi.org/project/tungsten-sds/">
<img src="https://raw.githubusercontent.com/CrucibleSDS/tungsten/main/assets/tungsten-wide-dark-bg-pad.png" align="center" alt="Tungsten" />
</a>
<h1 align="center">Tungsten</h1>
<p align="center">A material safety data sheet parser.</p>
</div>
## Installation
Tungsten is available on PyPi via pip. To install, run the following command:
```sh
pip install tungsten-sds
```
## Usage Example
```python
import json
from pathlib import Path
from tungsten import SigmaAldrichSdsParser, SdsQueryFieldName, \
SigmaAldrichFieldMapper
sds_parser = SigmaAldrichSdsParser()
sds_path = Path("CERILLIAN_L-001.pdf")
# Convert PDF file to parsed data
with open(sds_path, "rb") as f:
sds = sds_parser.parse_to_ghs_sds(f)
field_mapper = SigmaAldrichFieldMapper()
fields = [
SdsQueryFieldName.PRODUCT_NAME,
SdsQueryFieldName.PRODUCT_NUMBER,
SdsQueryFieldName.CAS_NUMBER,
SdsQueryFieldName.PRODUCT_BRAND,
SdsQueryFieldName.RECOMMENDED_USE_AND_RESTRICTIONS,
SdsQueryFieldName.SUPPLIER_ADDRESS,
SdsQueryFieldName.SUPPLIER_TELEPHONE,
SdsQueryFieldName.SUPPLIER_FAX,
SdsQueryFieldName.EMERGENCY_TELEPHONE,
SdsQueryFieldName.IDENTIFICATION_OTHER,
SdsQueryFieldName.SUBSTANCE_CLASSIFICATION,
SdsQueryFieldName.PICTOGRAM,
SdsQueryFieldName.SIGNAL_WORD,
SdsQueryFieldName.STATEMENTS,
SdsQueryFieldName.HNOC_HAZARD,
]
# Serialize parsed data to JSON and dump to a file
with open(sds_path.stem + ".json", "w") as f:
sds.dump(f)
# Also print out mapped fields
for field in fields:
print(field.name, field_mapper.get_field(field, json.loads(sds.dumps())))
```
## License
This work is licensed under MIT. Media assets in the `assets` directory are licensed under a
Creative Commons Attribution-NoDerivatives 4.0 International Public License.
## Notes
This library currently comes bundled with a new build of `tabula-java`, which is also licensed
under MIT, to see the full license, see https://github.com/tabulapdf/tabula-java/blob/master/LICENSE.
Raw data
{
"_id": null,
"home_page": "https://github.com/Den4200/tungsten",
"name": "tungsten-sds",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "sds,parser",
"author": "Dennis Pham",
"author_email": "dennis@dennispham.me",
"download_url": "https://files.pythonhosted.org/packages/8e/f0/d61b3a1af1838c479d060c5dc68a5bd20876f0fbfbee6db3742b518b97ed/tungsten_sds-0.8.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <a align=\"center\" href=\"https://pypi.org/project/tungsten-sds/\">\n <img src=\"https://raw.githubusercontent.com/CrucibleSDS/tungsten/main/assets/tungsten-wide-dark-bg-pad.png\" align=\"center\" alt=\"Tungsten\" />\n </a>\n <h1 align=\"center\">Tungsten</h1>\n <p align=\"center\">A material safety data sheet parser.</p>\n</div>\n\n## Installation\n\nTungsten is available on PyPi via pip. To install, run the following command:\n\n```sh\npip install tungsten-sds\n```\n\n## Usage Example\n\n```python\nimport json\nfrom pathlib import Path\n\nfrom tungsten import SigmaAldrichSdsParser, SdsQueryFieldName, \\\n SigmaAldrichFieldMapper\n\nsds_parser = SigmaAldrichSdsParser()\nsds_path = Path(\"CERILLIAN_L-001.pdf\")\n\n# Convert PDF file to parsed data\nwith open(sds_path, \"rb\") as f:\n sds = sds_parser.parse_to_ghs_sds(f)\n\nfield_mapper = SigmaAldrichFieldMapper()\n\nfields = [\n SdsQueryFieldName.PRODUCT_NAME,\n SdsQueryFieldName.PRODUCT_NUMBER,\n SdsQueryFieldName.CAS_NUMBER,\n SdsQueryFieldName.PRODUCT_BRAND,\n SdsQueryFieldName.RECOMMENDED_USE_AND_RESTRICTIONS,\n SdsQueryFieldName.SUPPLIER_ADDRESS,\n SdsQueryFieldName.SUPPLIER_TELEPHONE,\n SdsQueryFieldName.SUPPLIER_FAX,\n SdsQueryFieldName.EMERGENCY_TELEPHONE,\n SdsQueryFieldName.IDENTIFICATION_OTHER,\n SdsQueryFieldName.SUBSTANCE_CLASSIFICATION,\n SdsQueryFieldName.PICTOGRAM,\n SdsQueryFieldName.SIGNAL_WORD,\n SdsQueryFieldName.STATEMENTS,\n SdsQueryFieldName.HNOC_HAZARD,\n]\n\n# Serialize parsed data to JSON and dump to a file\nwith open(sds_path.stem + \".json\", \"w\") as f:\n sds.dump(f)\n # Also print out mapped fields\n for field in fields:\n print(field.name, field_mapper.get_field(field, json.loads(sds.dumps())))\n\n```\n\n## License\n\nThis work is licensed under MIT. Media assets in the `assets` directory are licensed under a\nCreative Commons Attribution-NoDerivatives 4.0 International Public License.\n\n## Notes\n\nThis library currently comes bundled with a new build of `tabula-java`, which is also licensed\nunder MIT, to see the full license, see https://github.com/tabulapdf/tabula-java/blob/master/LICENSE.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An MSDS parser.",
"version": "0.8.0",
"split_keywords": [
"sds",
"parser"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3bfafff50d3393a579d0f16fe612cc58bef1826d93a29ecdd53d900498256925",
"md5": "c9feb6eed844394ad65b7b1784b20cd5",
"sha256": "de1ec38287e0a315fda837f34fd125899428fcff4fe7125c1868fcb45fecfceb"
},
"downloads": -1,
"filename": "tungsten_sds-0.8.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c9feb6eed844394ad65b7b1784b20cd5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 12378094,
"upload_time": "2023-04-04T06:51:06",
"upload_time_iso_8601": "2023-04-04T06:51:06.298369Z",
"url": "https://files.pythonhosted.org/packages/3b/fa/fff50d3393a579d0f16fe612cc58bef1826d93a29ecdd53d900498256925/tungsten_sds-0.8.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8ef0d61b3a1af1838c479d060c5dc68a5bd20876f0fbfbee6db3742b518b97ed",
"md5": "e5e9c90476bf6ddf0fa9db769d525df1",
"sha256": "65d3d11768036bbdb2a65a8a06cb5b08e81091b7b3a9ca35a670096d36f9345c"
},
"downloads": -1,
"filename": "tungsten_sds-0.8.0.tar.gz",
"has_sig": false,
"md5_digest": "e5e9c90476bf6ddf0fa9db769d525df1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 12371383,
"upload_time": "2023-04-04T06:51:09",
"upload_time_iso_8601": "2023-04-04T06:51:09.280432Z",
"url": "https://files.pythonhosted.org/packages/8e/f0/d61b3a1af1838c479d060c5dc68a5bd20876f0fbfbee6db3742b518b97ed/tungsten_sds-0.8.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-04 06:51:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Den4200",
"github_project": "tungsten",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tungsten-sds"
}