Re: [Tutor] select particular directories and files

2011-08-30 Thread questions anon
Thanks, that also works really well. One of the hardest things I am finding with programming is that there is always more than one way to do something. This is a good and bad thing. Bad for beginners!! thanks On Tue, Aug 30, 2011 at 4:45 PM, Peter Otten <__pete...@web.de> wrote: > questions anon

Re: [Tutor] select particular directories and files

2011-08-29 Thread Peter Otten
questions anon wrote: > I am trying to select particular files within a particular subdirectory, I > have been able to do both but not together! > When I try to select my files within the dir loop nothing comes up, but > when I leave the files outside the dir loops it selects all the files > not j

Re: [Tutor] select particular directories and files

2011-08-29 Thread Andre' Walker-Loud
Hello anonymous questioner, > ok, thanks for your help Andre your welcome. hope you continue enjoying python. Andre > On Tue, Aug 30, 2011 at 2:37 PM, Andre' Walker-Loud > wrote: > to have multiple dirs is simple, > >> for dir in glob.glob(MainFolder + '*/01/') + glob.glob(MainFolder + '*

Re: [Tutor] select particular directories and files

2011-08-29 Thread questions anon
ok, thanks for your help Andre On Tue, Aug 30, 2011 at 2:37 PM, Andre' Walker-Loud wrote: > to have multiple dirs is simple, > > for dir in glob.glob(MainFolder + '*/01/') + glob.glob(MainFolder + > '*/02/') + glob.glob(MainFolder + '*/03/'): > > > there may be a better way, but this should work.

Re: [Tutor] select particular directories and files

2011-08-29 Thread Andre' Walker-Loud
to have multiple dirs is simple, > for dir in glob.glob(MainFolder + '*/01/') + glob.glob(MainFolder + '*/02/') > + glob.glob(MainFolder + '*/03/'): there may be a better way, but this should work. By the way, not to discourage you from asking questions on the list, but many of these things

Re: [Tutor] select particular directories and files

2011-08-29 Thread questions anon
It worked! thank you. This is the code I ended with: for dir in glob.glob(MainFolder + '*/01/'): print dir for ncfile in glob.glob(dir + '*.nc'): print ncfile can you choose more than one folder with glob? i.e. I tried: for dir in glob.glob(MainFolder + '*/01/', '*

Re: [Tutor] select particular directories and files

2011-08-29 Thread Andre' Walker-Loud
hello, yes, I would also try adding a wild card in the dir search >> for dir in glob.glob(MainFolder + '01\*'): to check if this is helps, in an interpreter (rather than script) try dirs = glob.glob(MainFolder + '\01\*'): print dirs if you get "[]" then this was not the answer, but if you ge

Re: [Tutor] select particular directories and files

2011-08-29 Thread questions anon
thanks, that was an error by me. but that still doesn't help me select the dir and files! Could it be because I am trying to select folders within other folders to then get a file from each of those folders? On Tue, Aug 30, 2011 at 1:30 PM, Andre' Walker-Loud wrote: > Dear Anonymous Questioner,

Re: [Tutor] select particular directories and files

2011-08-29 Thread Andre' Walker-Loud
Dear Anonymous Questioner, I am not sure how the Windows environment works, but in linux, I would replace > for ncfile in glob.glob('.nc'): with > for ncfile in glob.glob('*.nc'): ie, add the "wild card" '*' character to grab all files which end in '.nc' Andre On Aug 2

Re: [Tutor] select particular directories and files

2011-08-29 Thread questions anon
Thanks for responding When I try glob.glob I receive no errors but nothing prints. MainFolder=r"E:/Sample/" for dir in glob.glob(MainFolder + '01'): print "my selected directories are:", dir for ncfile in glob.glob('.nc'): print "my selected netcdf files are:", ncfile

Re: [Tutor] select particular directories and files

2011-08-29 Thread Emile van Sebille
On 8/29/2011 4:52 PM questions anon said... I am trying to select particular files within a particular subdirectory, You might find glob a better starting point: ActivePython 2.6.6.15 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Int

[Tutor] select particular directories and files

2011-08-29 Thread questions anon
I am trying to select particular files within a particular subdirectory, I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have s