How to convert a .vtu(Unstructured Grid) file to a .vtk(Rectilinear Grid) file?

How to convert a .vtu(Unstructured Grid) file to a .vtk(Rectilinear Grid) file?

import vtk
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFilname("path/to/file.vtu")

writer = vtk.vtkUnstructuredGridWriter()
writer.SetInputConnection(reader.GetOutputPort(0))
writer.SetFileName("path/to/file.vtk")
writer.Write()

An error was reported while running.
My requirement is to convert the unstructured grid into a structured grid. Can you convert the format with this code

I fixed it above.

Ha, I missed that. You need to use a ressampling filter.