Re: Search for a string in binary files
>>>>> "hokieghal99" == hokieghal99 <email@example.com> writes:
hokieghal99> Hello, How could I use python to search for a string
hokieghal99> in binary files? From the command line, I would do
hokieghal99> something like this on a Linux machine to find this
hokieghal99> grep -a "Microsoft Excel" *.xls
hokieghal99> How can I do this in Python?
Linux doesn't distinguish between binary files and regular files, so
you can use the usual string find method. On windows, you need to be
sure to open the file in binary mode
>>> s = file('temp.xls', 'rb').read()
The point is that there is nothing special about searching binary
files. Search the google groups archives for python grep for more
You can use regular expressions if you want to do more sophisticated
|All times are GMT. The time now is 10:50 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.