<br><br><div class="gmail_quote">On Thu, May 29, 2008 at 9:43 PM, Jean Favre <jfavre@cscs.ch> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
May I suggest the use of the python glob module.<br>
I have just tried it inside a programmable source and it works fine.<br>
Glob will look for all filenames following a pattern. You might also<br>
want to sort them alphabetically after you have created the array<br>
<br>
here is an example<br>
<br>
import glob<br>
<br>
files = glob.glob("file*.dat") # creates the array you wanted<br>
files.sort() # sorts them<br>
<br>
i = 0<br>
while i < len(files):<br>
print files[i]<br>
i = i + <font color="#888888"><br></font></blockquote><div><br>Thank you Robert and Jean.<br>Jean's idea indeed solved the file handling problem. <br>But now i found that the script is able to show only one curve at a time, i.e the last one in the file*.dat, eventhough it reads all the files.<br>
How do I solve the issue.? or is it that for each file I have to have different programmable filter.<br>Here is the script I used.. It would be great if some one can help me in this regard.<br>thanks in advance.<br>Sreejith<br>
<br>#!/usr/bin/python<br>import string, sys, math,glob<br>pdo = self.GetPolyDataOutput()<br>FILES=glob.glob("file_name*.dat")<br>FILES=sort()<br>for filename in FILES:<br> file=open(filename,'r')<br> point=0<br>
#This will store the points for the lines<br> newPts = paraview.vtkPoints()<br> for line in file:<br> #read x,y,z values<br> x = float( line.split()[0] )<br> y = float( line.split()[1] )<br> if(len(line.split())==3): # in 3D<br>
z = float( line.split()[2] )<br> else:<br> z=0.0 # in 2D<br> <br> newPts.InsertPoint(point, x,y,z)<br> point+=1<br> <br> pdo.SetPoints(newPts)<br> aPolyLine = paraview.vtkPolyLine()<br>
aPolyLine.GetPointIds().SetNumberOfIds(point)<br> for i in range(0,point):<br> aPolyLine.GetPointIds().SetId(i, i)<br> pdo.Allocate(1, 1)<br> pdo.InsertNextCell(aPolyLine.GetCellType(), aPolyLine.GetPointIds())<br>
file.close()<br><br><br><br></div></div><br>