Code to recognize MS-Word document files?

"Martin v. Löwis" martin at v.loewis.de
Tue Mar 4 11:51:53 EST 2003


Grant Edwards wrote:
> I'm looking for a snippet of python that I can use to determine
> if a file is a MS-Word document.  People around here seem to
> have gotten into the habit of attaching MS-Word files without a
> ".doc" on the name.  

The GNU file command can do this recognition, atleast partially. I'm not 
aware of a Python wrapper around it, but it shouldn't be too difficult.

GNU file will report MS-Word files as "Microsoft Office Document". 
Whether it is possible to infer them as "Word", I don't know.

Regards,
Martin





More information about the Python-list mailing list