RE: Opening MS Word files via Python

Discussion in 'Python' started by Tim Golden, Apr 21, 2004.

  1. Tim Golden

    Tim Golden Guest

    >I am curious as to how I should approach this issue. I would just
    >want to parse simple text and maybe perhaps tables in the future.
    >Would I have to save the word file and open it in a text editor? That
    >would kind of....suck... Has anyone else tackled this issue?


    Have a look at antiword: http://www.winfield.demon.nl/

    It's not written in Python (afaik) but it writes to stdout.
    Example:

    <code>
    import os

    ANTIWORD = "c:/antiword/antiword.exe"
    filename = raw_input ("Enter name of word doc: ")
    text = os.popen ("%s %s" % (ANTIWORD, filename)).read ()

    print text
    </code>

    TJG


    ________________________________________________________________________
    This e-mail has been scanned for all viruses by Star Internet. The
    service is powered by MessageLabs. For more information on a proactive
    anti-virus service working around the clock, around the globe, visit:
    http://www.star.net.uk
    ________________________________________________________________________
    Tim Golden, Apr 21, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen Witter

    opening a word doc in word not browser

    Stephen Witter, May 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    468
    Stephen Witter
    May 18, 2004
  2. Luis Esteban Valencia
    Replies:
    2
    Views:
    2,922
    sanjupillai
    Sep 26, 2008
  3. crazyprakash
    Replies:
    4
    Views:
    3,360
    adrian
    Oct 30, 2005
  4. Fazer
    Replies:
    5
    Views:
    21,786
  5. Jim Showalter
    Replies:
    1
    Views:
    279
    Joshua Cranmer
    Aug 26, 2008
Loading...

Share This Page