Newbie - unslicable type error etc
Sean 'Shaleh' Perry
shalehperry at home.com
Wed Oct 10 15:50:57 EDT 2001
> I have a large (7MB or so) file of raw hex data (ie values E{0,255})
> from which I need to identify a given byte sequence that occurs about
> 800 000 times within the file. Once I have found these data fragments
> I need to extract them to another file. My problem is that while I
> have been able to open the file and use read(10) etc to look at the
> file, I am unable to process it - I tried using input[23:67] (where
> 'input' is the name of the file I am working with) but python
> complained that I was using an unslicable type.
>
slices work on sequences, your variable 'input' is a file handle (like a FILE *
in C).
> So my question is how do I my file into a format where I am able to
> use RE's in python to play with it? When I input.read(10) it looks
> like:
>
> x05\x0A\x45\xA1...
>
> That is raw hex data. All suggestions most welcome.
>
http://py-howto.sourceforge.net/regex/regex.html is the regex howto. It may be
of help.
More information about the Python-list
mailing list