[Paraview] question on using python programmable source

Jean Favre jfavre at cscs.ch
Thu May 29 15:43:07 EDT 2008


On 29, May 2008 07:29 PM, Sreejith Kuttanikkad <sreejithpk at gmail.com>
wrote:

>
>but i would like to know more elegant way than writing each filenames
>in an
>array (difficult in the case when i have say 100 files)
>
 
May I suggest the use of the python glob module.
I have just tried it inside a programmable source and it works fine.
Glob will look for all filenames following a pattern. You might also
want to sort them alphabetically after you have created the array
 
here is an example
 
import glob
 
files = glob.glob("file*.dat")  # creates the array you wanted
files.sort()                         # sorts them
 
i = 0
while i < len(files):
    print files[i]
    i = i + 1
 
 
--
Jean
Swiss National Supercomputing Centre



More information about the ParaView mailing list