Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-25 Thread Gregory Lund
> Why did you change file mode to "a"? I was trying different things and forgot to change it back before I cut/pasted. > > > dest_path = os.path.dirname(fullpath) > x.extractall(dest_path) > Ding ding ding, winner winner chicken dinner! It's working! Final .py stand alone code is: import os, os.

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-24 Thread Gregory Lund
>> Near as I can tell, I got rid of the permissions error, the ZipFile >> error with the missing capital 'F' >> Now I need to 'get into' the non zipped folder of each student and >> unzip any and all zips that are inside of it. > > > The error message says 'No such file or directory'. That means th

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-24 Thread Gregory Lund
> No but Python did when it ran your code and it tried to tell you. The trick > is to read the error message, see what line of code it occurs at and then > look very closely at that line of code and the surrounding lines of code. > The first thing to check for is a typo. To be honest, I did check

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-24 Thread Gregory Lund
> > Capital F. ZipFile not Zipfile. > Keyboard - Forehead - SCHMACK. (and hand/forehead smack.) DOH! Thank you. Greg ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-24 Thread Gregory Lund
>> but now get a " x = zipfile.Zipfile(item,'r') >> AttributeError: 'module' object has no attribute 'Zipfile' " >> >> error >> >> gr, this is going to send me to the funny farm! >> >> greg >> > One way to avoid the "funny farm" is to learn to use the tools that > Python provides, built-in.

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-23 Thread Gregory Lund
> > but a better way to do that is: > if item.endswith('.zip') > >> x = zipfile.Zipfile(item,'r') >> x.extractall() >> x.close() >> ok, I used that (above) typed below: for item in zipContents: if item.endswith('.zip'): x = zipfile.Zipfile(item,'r') x.ex

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-23 Thread Gregory Lund
>>> > You're trying to open the directory as if it were a zipfile. You should >>> > pass in the path to a zipfile not to a folder. >>> >>> Agreed, but how do I do that "pass in the path to a zipfile'? >>> Using an if statement I presume? >>> >>> > > >>> >>> > > I guess my first issue is to resolve

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-23 Thread Gregory Lund
> > > > z.close > > You need to have round brackets to actually call the close method, i.e.: > > z.close() > Fixed > > > > > > It works, I get the following in the Python Shell: > > > > '>>> RESTART > > =

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-21 Thread Gregory Lund
> > You need to add the folder where python.exe is to your PATH variable. I just realized the path we're heading down here isn't going to work. I need on .py file to be up an running so that I can add it to my tool in ArcGIS. > > Oscar I appreciate the help Oscar, and I believe it would work th

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-20 Thread Gregory Lund
> > You need to add the folder where python.exe is to your PATH variable. > > First you need to find the folder where python is on your computer. You can > do this from within a python script using the following two lines: > import sys > print sys.executable > > Once you've found the folder contain

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-19 Thread Gregory Lund
On Wed, Sep 19, 2012 at 10:40 AM, Peter Otten <__pete...@web.de> wrote: > Steven D'Aprano wrote: > >> That's what we're here for! Don't be shy about asking questions. > > Indeed. Also, Gregory, don't expect anything to work directly. Programming > is mostly an iterative process where you write just

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-19 Thread Gregory Lund
>>> and then run it from the shell like this: On Wed, Sep 19, 2012 at 10:20 AM, Peter Otten <__pete...@web.de> wrote: > Gregory Lund wrote: >>> and then run it from the shell like this: ahh, windows shell, not python shell. from the directions Peter linked to, I shift-

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-19 Thread Gregory Lund
more info: > Consider it done, i have a new .py file saved as 'unzip_twice.py' but it would be easier (the whole purpose of this task) is to have a stand alone script that would work without having to open up the shell. In ArcGIS, I call the script by double clicking on my tool, selecting the .zi

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-19 Thread Gregory Lund
> Using Peter's code, if you create a plain text file called "unzip_twice.py" > containing: > > > import glob > import os > import sys > import zipfile > > source_file = sys.argv[1] > dest_folder = sys.argv[2] > > zipfile.ZipFile(source_file).extractall(dest_folder) > > inner_zips_pattern = os.path

Re: [Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-19 Thread Gregory Lund
> > Your lack of response in the previous thread > > http://mail.python.org/pipermail/tutor/2012-August/090742.html > > is not a big motivation to answer this one. I didn't have any response to post, I got the basics to work using a hint from a colleague in and was able to grade the assignment, ho

[Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.

2012-09-18 Thread Gregory Lund
I teach at a college and I'm trying to use Python (2.6 because I'm running my tool in ArcGIS) to unzip a .zip file that contains one folder full of student folders, each with 1 or more submissions (zipfiles) that represent student submissions to weekly lab assignments. It all starts with an origin

[Tutor] Unzip a zipfile, then unzip the zipfiles within the original zip

2012-08-07 Thread Gregory Lund
# neophyte .py/pyTutor user. # I am also a university GIS lecturer. My students submit their lab assignments (zipped up into one zipfile) to a depository, which I download as a single zip containing all 40 students' zipfiles. # Goal: unzip a zipfile of student zipfiles and then unzip each students'

[Tutor] How do I go from a textFile.txt to a list [] AND from a textFile.txt to a dictionary of dictionaries?

2012-07-22 Thread Gregory Lund
Only my second try to post to this list. This is a dumb question with a simple (I presume) solution... but... how do I take a txt file with semicolon separated values and create a dictionary and a list? ( in 2.6 because I'm working with ArcGIS.) text file is as follows: (saved as text_data.txt) (i

[Tutor] Reading a csv of coordinates, trying to write a csv of bearings.

2012-07-08 Thread Gregory Lund
I'm Not looking for an absolute solution, but perhaps some insight into some snippets of code, or suggestions of where I should seek out answers to this issue. Or where I've gone wrong below. NOTE: currently this 'code' below reads my file and writes a file, but what it's doing in the middl