Detecting Binary content in files

Benjamin Kaplan benjamin.kaplan at case.edu
Tue Mar 31 13:06:05 EDT 2009


On Tue, Mar 31, 2009 at 12:23 PM, ritu <ritu_bhandari27 at yahoo.com> wrote:

> Hi,
>
> I'm wondering if Python has a utility to detect binary content in
> files? Or if anyone has any ideas on how that can be accomplished? I
> haven't been able to find any useful information to accomplish this
> (my other option is to fire off a perl script from within m python
> script that will tell me whether the file is binary), so any pointers
> will be appreciated.
>


All files are binary. The question is whether every byte in the file
represents a (whole or part of a) character or whether some of the data
represents a different data type. You could theoretically have a "binary"
file that appears in a text editor to be perfect English. How does your perl
script tell the difference?



http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090331/de2c662f/attachment.html>


More information about the Python-list mailing list