Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

striprtf

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

striprtf

A simple library to convert rtf to text

  • 0.0.26
  • PyPI
  • Socket score

Maintainers
1

striprtf

Build status

Purpose

This is a simple library to convert Rich Text Format (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 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. :-)

Pushing to PyPi

  • pip install twine

Run commands

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

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc