how to do reading of binary files?

jvdb streamservenl at gmail.com
Fri Jun 8 08:16:30 EDT 2007


On 8 jun, 14:07, "Diez B. Roggisch" <d... at nospam.web.de> wrote:
> jvdb schrieb:
......
> What has the searching to do with the reading? 10MB easily fit into the
> main memory of a decent PC, so just do
>
> contents = open("file").read() # yes I know I should close the file...
>
> print contents.find('\x0c')
>
> Diez

True. But there is another issue attached to the one i wrote.
When i know how much this occurs, i know the amount of pages in the
file. After that i would like to be able to extract a given amount of
data:
file x contains 20 <0C>. then for example i would like to extract from
instance 5 to instance 12 from the file.
The reason why i want to do this: The 0C stands for a pagebreak in PCL
language. This way i would be absle to extract a certain amount of
pages from the file.






More information about the Python-list mailing list