[Paraview] question on using python programmable source
Robert Maynard
robertjmaynard at gmail.com
Thu May 29 13:53:48 EDT 2008
You should look into the python os module
Something like this might work:
import os
FILE = "file.dat"
(filePath,fileName) = os.path.split(FILE)
(name,ext) = os.path.splitext(fileName)
allFiles = os.listdir(filePath)
for otherFile in allFiles:
(otherName, otherExt) = os.split.splitext(otherFile)
if (otherExt == ext):
#load other file
Sreejith Kuttanikkad wrote:
> Dear,
> I have number of files with each file contains many points (x,y,z
> coordinates) of a line/curve. I use python programmable source to
> visualize those lines (like the example given to generates a Helix
> curve in the paraview Wiki.)
> I use file=fopen("file1",'r') and extract the coordinates of each
> point from the file and visualize that line.. and it is working great.
> now the problem is, i have so many files (many lines) and i want to
> see all the lines at once.
> so i could use like
>
> FILES=["file1.dat","file2.dat", ..... ]
> for filename in FILES:
> file=open(filename,'r')
>
> 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)
>
> any tips and tricks..?
> thank you
> Sreejith
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview
>
More information about the ParaView
mailing list