twneale
twneale

Reputation: 2946

Read WordPerfect files with Python?

I really need to work with information contained in WordPerfect 12 files without using WordPerfect's sluggish visual interface, but I can't find any detailed documentation about the file format or any Python modules for reading/writing the files. I found a post on the web that seems to explain how to convert WordPerfect to text, but I didn't understand much about how it works.

http://mail.python.org/pipermail/python-list/2000-February/023093.html

How do I accomplish this?

Upvotes: 0

Views: 1893

Answers (3)

twneale
twneale

Reputation: 2946

OK, here's what I did. I read the file in binary mode, converted by the data into a string representation of the hex values, and used unofficial WordPerfect documentation to create regular expressions to swap out all the hex strings representing non-text formatting codes and meta data, then converted everything back into text.

A dirty piece of hacking, but it got the job done.

Upvotes: 1

John Fouhy
John Fouhy

Reputation: 42183

OpenOffice.org should read WordPerfect files, I think.

And you can script OpenOffice with Python.

Upvotes: 2

Mark
Mark

Reputation: 108507

The relevant part of your link is this:

os.system( "%s %s %s" % ( WPD_TO_TEXT_CMD, "/tmp/tmpfile", "/tmp/tmpfile.txt" ) )

Which is making a system call to an outside program called "wp2txt". Googling for that program produces active hits.

Upvotes: 3

Related Questions