pythonwordperfect

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?


Solution

  • 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.