Hans Hans - 1 year ago 216
Python Question

paraview python scripting equivalent of File->save Data

I would like to automate exporting csv files from vtk/vtu files.

Right now, the steps I take are:

  • open paraview

  • load in the pvd file that stores the information about all vtu files (one for each time steps in my PDE simulation)

  • goto Properties tab on the left, hit 'apply'

  • File->save Data... provide a base file name, select 'points' and 'write all timesteps'

this writes a csv file for each timesteps with the name basefilename#timestepno#.csv

Is there a way to do this from the commandline (there's no X server on the computer that's doing the computations), eg using the python interface?

Answer Source

Try the following in either the Python Shell in the UI or using the pvpython or pvbatch Python executables.

from paraview import simple
reader = simple.OpenDataFile("..../foo.pvd")
writer = simple.CreateWriter("..../foo.csv", reader)
writer.WriteAllTimeSteps = 1
writer.FieldAssociation = "Points"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download