-2
import subprocess
import os

filename="D:\MAINTRUNK\ar_ctrl_handle_ar_expand_menu.ptu"
r = subprocess.Popen("open " + filename,     stdout=subprocess.PIPE, shell=True, universal_newlines=True)

stdout, stderr = r.communicate()

print stdout
Tom Zych
  • 13,329
  • 9
  • 36
  • 53
Aashiq
  • 11
  • `open` bash command (on a Mac?) will open Office application, not read a file (regardless if from svn) – OneCricketeer Jul 16 '18 at 14:07
  • In any case, what's a PTU file? – OneCricketeer Jul 16 '18 at 14:08
  • Your `filename` string is bad; make it a raw string to avoid the backslashes being interpreted as escapes. – Tom Zych Jul 16 '18 at 14:08
  • 2
    You included code, good. But it’s not clear to me, at least, exactly what you are trying to do, or how this code fails to do it. Please clarify? Show some example data and the output you want. – Tom Zych Jul 16 '18 at 14:11
  • It depends strongly on what kind of files you want read. Do you just want to get the content of word-documents? – Jones1220 Jul 16 '18 at 14:17

2 Answers2

1

it's extracting the content of a word file.

import docx2txt
text= docx2txt.process("file_name.docx")
0

There exists a module that can help you reading in the content of a .doc file

import textract
text = textract.process(r"D:\MAINTRUNK\ar_ctrl_handle_ar_expand_menu.doc")

For more info and alternatives see the answers of a similar question : Read .doc file with python

Chuk Ultima
  • 987
  • 1
  • 11
  • 21