[Tutor] Zipfile and File manipulation questions.

Chris Hengge pyro9219 at gmail.com
Mon Oct 16 02:30:56 CEST 2006


After getting some sleep and looking at my code, I think I was just to tired
to work through that problem =P

Here is my fully working and tested code..
Thanks to you all for your assistance!

if "/" in afile:
    aZipFile = afile.rsplit('/', 1)[-1] # Split file based on criteria.
    outfile = open(aZipFile, 'w') # Open output buffer for writing.
    outfile.write(zfile.read(afile)) # Write the file.
    outfile.close() # Close the output file buffer.
elif "\\" in afile:
    aZipFile = afile.rsplit('\\', 1)[-1] # Split file based on criteria.
    outfile = open(aZipFile, 'w') # Open output buffer for writing.
    outfile.write(zfile.read(afile)) # Write the file.
    outfile.close() # Close the output file buffer.
else:
    outfile = open(afile, 'w') # Open output buffer for writing.
    outfile.write(zfile.read(afile)) # Write the file.
    outfile.close() # Close the output file buffer.

On 10/15/06, Kent Johnson <kent37 at tds.net> wrote:
>
> Chris Hengge wrote:
> > I must have not been clear.. I have a zip file with folders inside..
> > When I extract it.. I dont want the folder structure, just the files..
> >
> > using split doesn't seem to help in this situation.. unless I'm not
> > putting the results in the right spot..
>
> Can you show us what you tried? split() can definitely help here.
>
> Kent
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061015/9ac0e0fa/attachment.html 


More information about the Tutor mailing list