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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

striprtf-0.0.33.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

striprtf-0.0.33-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file striprtf-0.0.33.tar.gz.

File metadata

  • Download URL: striprtf-0.0.33.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for striprtf-0.0.33.tar.gz
Algorithm Hash digest
SHA256 c2d3d9ff3118df6dab558675f10a31ff8bb999ac1f8921f00c6dc9ea19961f18
MD5 182ace6828f5084eea54d6a9b1167a68
BLAKE2b-256 3e3bc42830804cb2da515d0cb8aa200fb199ce57f7dcc344ff73db9dfe37cf3b

See more details on using hashes here.

File details

Details for the file striprtf-0.0.33-py3-none-any.whl.

File metadata

  • Download URL: striprtf-0.0.33-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for striprtf-0.0.33-py3-none-any.whl
Algorithm Hash digest
SHA256 f9637632a4414de05b1c399ee34d324dc336133ae45769992143a024e0f919ef
MD5 758f69b04712b14ded1b34dd24b90505
BLAKE2b-256 f585bee751fd2096accfc8b76186d49fbb2871163723e45f1e721e03c3f044ae

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.33 This release

2 files

0.0.32

2 files

0.0.31

2 files

0.0.30

2 files

0.0.29

2 files

0.0.28

2 files

0.0.27

2 files

0.0.26

2 files

0.0.25

2 files

0.0.24

2 files

0.0.23

2 files

0.0.22

2 files

0.0.21

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

1 file

0.0.10

1 file

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

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