Skip to main content

striprtf

Build status

Purpose

This is a library to convert Rich Text Format (RTF) files to plain text files. 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

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.

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:

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 available.

PostgreSQL

There is also a PostgreSQL version available from Raffael Mancini.

History

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. :-)

Metadata

Release files for striprtf 0.0.35

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for striprtf 0.0.35
File Size Uploaded Provenance Actions
striprtf-0.0.35.tar.gz 8.0 kB Without provenance Details for striprtf-0.0.35.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for striprtf 0.0.35
File Interpreter ABI Platform Actions
striprtf-0.0.35-py3-none-any.whl Python 3 none any Details for striprtf-0.0.35-py3-none-any.whl

Total release size: 16.5 kB

Release files / striprtf-0.0.35.tar.gz

Download URL striprtf-0.0.35.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a21e8c4f73a791c3f23561df96701488c691ab1749a92487cc9e5fee6ea08455
BLAKE2b-256 checksum
How to use checksums
25ec008fd13d23376e8f7a2f24f56381245218fb2322a17c41c4f944f54eeff9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / striprtf-0.0.35-py3-none-any.whl

Download URL striprtf-0.0.35-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c8e207f47c9de355374d604167b17c99a06eb4d238e07cfba772f8669db60e4
BLAKE2b-256 checksum
How to use checksums
4132896d0597748a55913033a3a52de9a9449d0d479a1ac733a1e0178a537170
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Security for striprtf 0.0.35

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.

Release history Release notifications | RSS feed

This release

0.0.35 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page