Skip to main content

A simple library to convert rtf to text

Project description

striprtf

Build status

Purpose

This is a simple library to convert 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

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 utf-8 to can pass the parameter encoding.

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)

How to use online

If you don't want to install, there is also an online version available at https://striprtf.dev which can be used for free.

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.

Pushing to PyPi

  • pip install twine

Run commands

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

Project details


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.23.tar.gz (5.4 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.23-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: striprtf-0.0.23.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.10

File hashes

Hashes for striprtf-0.0.23.tar.gz
Algorithm Hash digest
SHA256 b3248c6ee32a2bc0cb91b2f19bac9b0611ce0d9be788638e68f1228ecee33095
MD5 6d21b3ceaac2f09c38772c24468d7a42
BLAKE2b-256 7f217e3c694851c2dcfe7c4b13a0ed5f3736fdedcb70bf6493dc98c36884f376

See more details on using hashes here.

File details

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

File metadata

  • Download URL: striprtf-0.0.23-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.10

File hashes

Hashes for striprtf-0.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 b72d900c99ef89a336f625945cdbf274674a51714f74814ad00393f6aacac805
MD5 e5427da39466b217e171999e40f5e9ca
BLAKE2b-256 fa3027fc0b68f26af306ad817030b55d258cb229ea1004ec72b63549172628c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page