[Tutor] counting no of words

Liam Clarke cyresse at gmail.com
Thu Jan 20 21:59:40 CET 2005


I'd take the easy way out and use winPython's COM objects to open the
doc in word, and save it as .txt
and then - 

f=file("doc.txt",'r')
j=f.read()
j=j.split(" ")
print len(j)



On Thu, 20 Jan 2005 13:59:16 -0500, Roger Merchberger
<zmerch at 30below.com> wrote:
> Rumor has it that Bill Mill may have mentioned these words:
> >[snip]
> >Once you're connected to a word document, you'll have to figure out
> >what the command to count the words in the document is, but that's
> >just a matter of recording a macro in word where you count the words,
> >then repeating it in python.
> 
> Another option would be to write the python program from within
> OpenOffice.org if it's available -- it has facilities of opening and
> accessing word documents as well.
> 
> >I'd help you with that, but I'm on linux.
> 
> Most things I do are on Linux as well; but the OpenOffice solution should
> work equally well on either platform.
> 
> HTH,
> Roger "Merch" Merchberger
> 
> --
> Roger "Merch" Merchberger  --  SysAdmin, Iceberg Computers
> zmerch at 30below.com
> 
> Hi! I am a .signature virus.  Copy me into your .signature to join in!
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.


More information about the Tutor mailing list