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

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.34
File Size Uploaded Provenance Actions
striprtf-0.0.34.tar.gz 8.0 kB Without provenance Details for striprtf-0.0.34.tar.gz

Built distribution (wheel)

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

Total release size: 16.5 kB

Release files / striprtf-0.0.34.tar.gz

Download URL striprtf-0.0.34.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0c46348df545f0a43e357d1387ab6a3eb9e23b22ade1e77191550b129c05b2a7
BLAKE2b-256 checksum
How to use checksums
d9940454ad1381ac857559ffa92eb535a763b7468a92f5804990e9116f78115f
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.34-py3-none-any.whl

Download URL striprtf-0.0.34-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32113e70a99d00e7f0f64d4850c3ad11126501e200aeb29c5270526a6eba52e2
BLAKE2b-256 checksum
How to use checksums
f1b82992ae67a298f2da346116df25b6e84efddb239ebb3fb5b6943286fe4e52
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.34

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