I want to extract data arrays from a .vtu file using the Python VTK module. The file looks like this (the raw data at the end of the file is ommitted):
You are not using the right reader, this is a .vtu
file, you have to use the vtkXMLUnstructuredGridReader
.
import vtk.vtk
# The source file
file_name = "path/to/your/file.vtu"
# Read the source file.
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(file_name)
reader.Update() # Needed because of GetScalarRange
output = reader.GetOutput()
potential = output.GetPointData().GetArray("potential")