[Tutor] directory within directory

questions anon questions.anon at gmail.com
Fri Aug 19 08:16:58 CEST 2011


Excellent, thank you!!

On Wed, Aug 17, 2011 at 5:43 PM, Peter Otten <__peter__ at web.de> wrote:

> questions anon wrote:
>
> > Thank you, that does create the directories in the new place but when I
> > process the data it does not put the outputs in the correct directory
> they
> > all end up in the last directory created.
> > Below is the code of what I am trying to do.
> > Any feedback will be greatly appreciated.
>
> I think
>
> > for (path, dirs, files) in os.walk(inputpath):
> >     for dir in dirs:
> >         print dir
> >         sourcepath=os.path.join(path,dir)
> >         relativepath=os.path.relpath(sourcepath,inputpath)
> >         newdir=os.path.join(outputpath,relativepath)
>
> the following two lines
>
> >     if not os.path.exists(newdir):
> >         os.makedirs(newdir)
>
> belong in the for-dirs-loop. plt.savefig() belongs into the for-ncfile loop
> and needs a path based on the path variable:
> >
> >     for ncfile in files:
> >         if ncfile[-3:]=='.nc':
>           ...
>              relativepath = os.path.relpath(path, inputpath)
>               newdir = os.path.join(outputpath, relativepath)
>
>  plt.savefig((os.path.join(newdir,'TSFC'+date_string+'UTC.png')))
>
> All untested guesswork. I don't see how you ensure that you get a new
> figure
> for each *.nc file and am too lazy to consult the matplotlib
> documentation...
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110819/84c8e53e/attachment.html>


More information about the Tutor mailing list