Extract sigle file from zip file based on file extension

Peter Otten __peter__ at web.de
Fri Feb 10 04:03:57 EST 2017


loial wrote:

> I need to be able to extract a single file from a .zip file in python.
> The zip file will contain many files. The file to extract will be the only
> .csv file in the zip, but the full name of the csv file will not be known.
> 
> Can this be done in python?

See <https://docs.python.org/dev/library/zipfile.html>

It should not take you more than five minutes to work this out yourself.
Hint: have a look at the extract() and namelist() methods.




More information about the Python-list mailing list