![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
Hi
I am writing a liitle program, that is supposed to read in a file into a songle string. Can python recognize a word file, and if yes, which thingy in the end do I use (like *.txt for NotePad stuff). Thanks for any help Fred |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Looks like for text files the extension .txt is most common.
If you create the file, you can put in a marker up front like the word 'text' that your program then recognizes.
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
With word files I actually meant:
files created in "Word"... --> sry for the misunderstanding And I just found out, that *.txt does not work for those. Any ideas, in how to change the document type using python? Would be an interesting project! |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
Whoever is interested in it:
I found a way to open and read-in text files written in word: import win32com.client
import tkFileDialog
# Launch Word
MSWord = win32com.client.Dispatch("Word.Application")
MSWord.Visible = 0
# Open a specific file
myWordDoc = tkFileDialog.askopenfilename()
MSWord.Documents.Open(myWordDoc)
#Get the textual content
docText = MSWord.Documents[0].ContentThe link to the site is: http://mail.python.org/pipermail/pyt...il/217741.html Fred |
|
|
|
|
|
#5 | |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Quote:
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
|
#6 |
|
Programmer
Join Date: Feb 2005
Posts: 67
Rep Power: 4
![]() |
Yup!
Google rocks my world!!! D: |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|