Sniffing Text Files

David Pratt fairwinds at eastlink.ca
Fri Sep 23 11:09:40 EDT 2005


Thanks Mike this is really great!

Regards,
David

On Friday, September 23, 2005, at 11:55 AM, Mike Meyer wrote:

> David Pratt <fairwinds at eastlink.ca> writes:
>> Thanks Mike for your reply.  I am not aware of libmagic and will look
>> to see what it provides.
>
> and ...
>
> Skip Montanaro <skip at pobox.com> writes:
>> You can also run the file(1) command and see what it says.  I seem
>> to recall someone asking about the equivalent to file(1) implemented 
>> in
>> Python awhile back.
>
> libmagic is the smarts of the file command. As I said before, people
> have done Python wrappers for it. It uses a text database describing
> how to recognize a files type - see the magic(5) man page for details
> on that. If you use libmagic, you'll probably want to provide your own
> version of the databse, excerpted to include just the file types you
> want to recognize.
>
> You can check on whether or not this will work for you by seeing what
> the file command says about your sample data.
>
>     <mike
> -- 
> Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
> Independent WWW/Perforce/FreeBSD/Unix consultant, email for more 
> information.
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list