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.22.tar.gz (5.3 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.22-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: striprtf-0.0.22.tar.gz
  • Upload date:
  • Size: 5.3 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.22.tar.gz
Algorithm Hash digest
SHA256 4fbadbe8424f412b5b263bf72fb3c0dab4ddb574d609dd4d084f6e2b8b04402b
MD5 7c45b8914621245d282c8f6b764aae92
BLAKE2b-256 501f61964db845c7e7720982556adcae899e2f54b7eb1a90ff3a2b0d4feabc2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: striprtf-0.0.22-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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.22-py3-none-any.whl
Algorithm Hash digest
SHA256 af480904ede039c7bbfc2c18c7e5326bff61093c06aab6dbbc3a1d0dfc24a347
MD5 930f5bc06080fad8d4c69e3e5fb455c0
BLAKE2b-256 4aa956b5cef23c678b73636bd25d886d4d8c40ff616e86b3912d015bd175d26c

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