using python to parse md5sum list

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sun Mar 6 17:24:02 EST 2005


In <mailman.3383.1110082800.22381.python-list at python.org>, James Stroud
wrote:

> If you are using md5sum, tou can grab the md5 and the filename like such:
> 
> myfile = open(filename)
> md5sums = []
> for aline in myfile.readlines():
>   md5sums.append(aline[:-1].split("  ",1))

  md5sums.append(aline[:-1].split(None, 1))

That works too if md5sum opened the files in binary mode which is the
default on Windows.  The filename is prefixed with a '*' then, leaving
just one space between checksum and filename.

> myfile.close()

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list