Saving data as .csv files

Hi Justin,

I actually had a similar question. Could you help me with it? Thanks!

The website does not allow me to post vtu file, but I got my vtu using this mfx file. vtu.mfx (13.6 KB)

Then I used the following code to extract data


import numpy as np
import vtk
from vtk.util.numpy_support import vtk_to_numpy

reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(“BACKGROUND_IC_0005.vtu”)
reader.Update()
data = reader.GetOutput()

point_data = data.GetPointData()
for i in range(point_data.GetNumberOfArrays()):
print(i, point_data.GetArrayName(i), ‘Components:’, point_data.GetArray(i).GetNumberOfComponents())


But I didn’t see anything printing out. Did I misunderstand somewhere on how to use the code?

Thanks,
Jack