auto read multiple files

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Thu May 9 12:18:52 EDT 2002


On Thursday 09 May 2002 2:58 pm, Rad wrote:
> Hi,
>
> I have about 2500 text files to read (and manipulate) from apx. 625
> directories (i.e. 4 files per directory) eg:
> C:\Python22\data\ProjectName\001\FileName1.001
> 				 FileName2.001
> 				 FileName3.001
> 				 FileName4.001
> C:\Python22\data\ProjectName\002\FileName1.002
> 				 FileName2.002
> 				 FileName3.002
> 				 FileName4.002
> 

> 

> C:\Python22\data\ProjectName\625\FileName1.625
> 				 FileName2.625
> 				 FileName3.625
> 				 FileName4.625
> I want to apply the same procedure/s to all(625) sets of four files
> without having to explicitly specify paths and FileNames, i.e. run the
> program and leave it over night to do the work on all 2500 files.
> I could create a list of all the file names and use it to access files
> 4 by 4 but I guess this is not the best way.
>

I guess a for loop like:
stub='C:\Python22\data\ProjectName\*'
for number in glob.glob(stub + '*'):
    file1=os.path.join(stub, number, 'FIlename1.%i' %number)













More information about the Python-list mailing list