[Tutor] reading nested folders in gzip files

Kent Johnson kent37 at tds.net
Mon May 18 19:28:13 CEST 2009


On Mon, May 18, 2009 at 12:34 PM, Dinesh B Vadhia
<dineshbvadhia at hotmail.com> wrote:
> The structure of the gzip files are:
>
> gzip archive
>     folderA
>         folderB
>             list of folderC's
>                 each folderC contains the target files
>
> Within the archive, I want to open the gzip archive, open folderA,
> openFolderB , get the list of target files in folderC, and extract each file
> in folderC individually.
>
> I've used gzip before but cannot see how to move from folderA to folder B
> within the archive.  Any ideas?

Presumably the gzip file is a tar archive? If so see the examples for
the tarfile module, they show something very similar to what you need.
The fourth example shows how to see what is in the file and the first
example shows how to filter it.
http://docs.python.org/library/tarfile.html#examples

Kent


More information about the Tutor mailing list