striprtf


Namestriprtf JSON
Version 0.0.27 PyPI version JSON
download
home_pagehttps://github.com/joshy/striprtf
SummaryA simple library to convert rtf to text
upload_time2024-11-07 20:20:02
maintainerNone
docs_urlNone
authorJoshy Cyriac
requires_pythonNone
licenseBSD-3-Clause
keywords rtf
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # striprtf
![Build status](https://github.com/joshy/striprtf/workflows/striprtf%20build/badge.svg)

## Purpose
This is a simple library to convert Rich Text Format (RTF) files to python strings. 
A lot of medical documents are written in RTF format which is not ideal for parsing
and further processing. This library converts it to plain old text.

## How to use it
```python
from striprtf.striprtf import rtf_to_text
rtf = "some rtf encoded string"
text = rtf_to_text(rtf)
print(text)
```

If you want to use a different encoding than `cp1252` you can pass it via the `encoding`
parameter. This is only taken into account if no explicit codepage has been set. 
```python
from striprtf.striprtf import rtf_to_text
rtf = "some rtf encoded string in latin1"
text = rtf_to_text(rtf, encoding="latin-1")
print(text)
```

Sometimes UnicodeDecodingErrors can happen because of various reasons.
In this case you can try to relax the encoding process like this:
```python
from striprtf.striprtf import rtf_to_text
rtf = "some rtf encoded string"
text = rtf_to_text(rtf, errors="ignore")
print(text)
```

## Online version
If you don't want to install or just try it out there is an [online version](https://striprtf.dev) available. 

## PostgreSQL 
There is also a [PostgreSQL version](https://github.com/MnhnL/pg_striprtf) available from [Raffael Mancini](https://github.com/raffael-mnhn).

## History
[Pyth](https://github.com/brendonh/pyth) was not working for the rtf files I
had. The next best thing was this gist:
https://gist.github.com/gilsondev/7c1d2d753ddb522e7bc22511cfb08676

~~Very few additions where made, e.g. better formatting of tables. ~~

In the meantime some encodings bugs have been fixed. :-)

## Pushing to PyPi
 * pip install twine

Run commands
```
python setup.py sdist bdist_wheel
twine upload -r testpypi dist/*
twine upload -r pypi dist/*
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/joshy/striprtf",
    "name": "striprtf",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "rtf",
    "author": "Joshy Cyriac",
    "author_email": "joshy@posteo.ch",
    "download_url": "https://files.pythonhosted.org/packages/01/f5/6e9dd580a523f36eb70ee48c8182b4fe35e62799b45a51b13e896ab1b1c1/striprtf-0.0.27.tar.gz",
    "platform": null,
    "description": "# striprtf\n![Build status](https://github.com/joshy/striprtf/workflows/striprtf%20build/badge.svg)\n\n## Purpose\nThis is a simple library to convert Rich Text Format (RTF) files to python strings. \nA lot of medical documents are written in RTF format which is not ideal for parsing\nand further processing. This library converts it to plain old text.\n\n## How to use it\n```python\nfrom striprtf.striprtf import rtf_to_text\nrtf = \"some rtf encoded string\"\ntext = rtf_to_text(rtf)\nprint(text)\n```\n\nIf you want to use a different encoding than `cp1252` you can pass it via the `encoding`\nparameter. This is only taken into account if no explicit codepage has been set. \n```python\nfrom striprtf.striprtf import rtf_to_text\nrtf = \"some rtf encoded string in latin1\"\ntext = rtf_to_text(rtf, encoding=\"latin-1\")\nprint(text)\n```\n\nSometimes UnicodeDecodingErrors can happen because of various reasons.\nIn this case you can try to relax the encoding process like this:\n```python\nfrom striprtf.striprtf import rtf_to_text\nrtf = \"some rtf encoded string\"\ntext = rtf_to_text(rtf, errors=\"ignore\")\nprint(text)\n```\n\n## Online version\nIf you don't want to install or just try it out there is an [online version](https://striprtf.dev) available. \n\n## PostgreSQL \nThere is also a [PostgreSQL version](https://github.com/MnhnL/pg_striprtf) available from [Raffael Mancini](https://github.com/raffael-mnhn).\n\n## History\n[Pyth](https://github.com/brendonh/pyth) was not working for the rtf files I\nhad. The next best thing was this gist:\nhttps://gist.github.com/gilsondev/7c1d2d753ddb522e7bc22511cfb08676\n\n~~Very few additions where made, e.g. better formatting of tables. ~~\n\nIn the meantime some encodings bugs have been fixed. :-)\n\n## Pushing to PyPi\n * pip install twine\n\nRun commands\n```\npython setup.py sdist bdist_wheel\ntwine upload -r testpypi dist/*\ntwine upload -r pypi dist/*\n```\n\n\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "A simple library to convert rtf to text",
    "version": "0.0.27",
    "project_urls": {
        "Download": "https://github.com/joshy/striprtf/archive/v0.0.27.tar.gz",
        "Homepage": "https://github.com/joshy/striprtf"
    },
    "split_keywords": [
        "rtf"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7e8741f6a04b93bf94421a2357b3f81ef439c3b97a80e33d5bd8fc9b6c3e04b2",
                "md5": "743f2f1674d90b504ad434a825821fc3",
                "sha256": "eae6f2e14ba04ef3eaa4b488a3417f3937696e68f3e5e4ebb77edb23498fd819"
            },
            "downloads": -1,
            "filename": "striprtf-0.0.27-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "743f2f1674d90b504ad434a825821fc3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7638,
            "upload_time": "2024-11-07T20:20:00",
            "upload_time_iso_8601": "2024-11-07T20:20:00.380315Z",
            "url": "https://files.pythonhosted.org/packages/7e/87/41f6a04b93bf94421a2357b3f81ef439c3b97a80e33d5bd8fc9b6c3e04b2/striprtf-0.0.27-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "01f56e9dd580a523f36eb70ee48c8182b4fe35e62799b45a51b13e896ab1b1c1",
                "md5": "3da95d9de72e6fe59e38a70d290b8740",
                "sha256": "cb7653dda023fd3e2c6455d2bac2580fb1c624774a78b249e815890c9dc37669"
            },
            "downloads": -1,
            "filename": "striprtf-0.0.27.tar.gz",
            "has_sig": false,
            "md5_digest": "3da95d9de72e6fe59e38a70d290b8740",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7149,
            "upload_time": "2024-11-07T20:20:02",
            "upload_time_iso_8601": "2024-11-07T20:20:02.069115Z",
            "url": "https://files.pythonhosted.org/packages/01/f5/6e9dd580a523f36eb70ee48c8182b4fe35e62799b45a51b13e896ab1b1c1/striprtf-0.0.27.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-07 20:20:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "joshy",
    "github_project": "striprtf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "striprtf"
}
        
Elapsed time: 0.42828s