[python-win32] print file byte contents distribution

Ghostly ghostility at gmail.com
Fri Mar 4 18:24:42 CET 2011


Hi,

As I don't see any CLI tool other then hex editor, I thought on writing
small script that will display byte distribution from file content

So I thought on this:

-----------------------------
counter = {}

for bytes in open('c:\\temp\\bin.dat', "rb").read():
    counter[bytes] = counter.get(bytes, 0) + 1

print counter
-----------------------------

It works fine, but as I need to parse large file data, I thought to ask
if someone knows a better way of doing this

Thanks


More information about the python-win32 mailing list