Group Abstract Group Abstract

Message Boards Message Boards

0
|
19K Views
|
4 Replies
|
4 Total Likes
View groups...
Share
Share this post:

How can I remove the formatting from imported RTF (Rich Text Format) files?

Posted 11 years ago

Hi everyone,

How can I strip away the formatting and leave only the text when I import an RTF?

I've imported as

Import[myFile, "RTF"]

Gregory

POSTED BY: Gregory Lypny
4 Replies
Attachments:
POSTED BY: Hans Michel
Posted 11 years ago

Hey Hans,

Thanks a load for this. Method 2 works the best and is flexible. The only formatting it leaves behind is the occasional bit of font information wrapping a table here and there. That' easy to get rid of.

Kind regards,

Gregory

POSTED BY: Gregory Lypny

Gregory,

Maybe try something like this:

nb = Last[
  Import["C:\\Users\\YourName\\Desktop\\This is an RTF file.rtf", "Rules"]]

That should open a new notebook that contains the text contents of the RTF file. From there, I think you should be able to programmatically do whatever you want with the text.

POSTED BY: Tim Mayes
Posted 11 years ago

Thank you, Tim,

I'll look into the stuff on rules. Haven't used that until now.

Gregory

POSTED BY: Gregory Lypny
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard