reading and removing first x bytes of a file

Brian Gough bjg at network-theory.co.uk
Thu Apr 29 10:27:40 EDT 2004


bart_nessux <bart_nessux at hotmail.com> writes:

> I have some Macbinary files on a PC. I want to recursively read these 
> files and remove the first 128 bytes of the files if they contain the 
> macbinary header info. I know how to read directories recursively, but 
> how would I read the first 128 bytes of each file in the path?

You can use the file object .seek() and .read() methods to move around
in the file and read parts of it.

There is an example in the "Input and Output" chapter of the Python
Tutorial.

-- 
Brian Gough

Network Theory Ltd,
Publishing the Python Manuals --- http://www.network-theory.co.uk/



More information about the Python-list mailing list