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] =
What a nifty script! I love it!
Here's my version. I tested using a 800 KByte image file and it runs
in a blink. Dictionary access in Python is very fast.
code
counter = {}
for bytes in open('c:\\temp\\16.jpg', rb).read():
try:
counter[bytes] += 1
except KeyError:
Thanks guys for your input
As I need this for larger files (couple of tens even hundrets of MB) I
tested your suggestion and it seems that dict method is fastest.
I ended with this:
import sys
try:
counter = {}
for bytes in open(sys.argv[1], rb).read():
Ghostly wrote:
Thanks guys for your input
As I need this for larger files (couple of tens even hundrets of MB) I
tested your suggestion and it seems that dict method is fastest.
I decided to find out, so I ran timeit on both schemes using a 2MB
file. The two methods are within 1% of each