CSV table data to 3D

One way to achieve this is to use a Programmable Source.

  1. Source > Alphabetical > Programmable Source
  2. Fill in the Script (RequestInformation) as shown below.
from paraview import util
util.SetOutputWholeExtent(self, [0, 98, 0, 37, 0, 0])

Here, the values to be specified for SetOutputWholeExtent are obtained by counting the number of rows and columns from the csv file in advance.

  1. Enter the following in Script.
import numpy as np

path = 'data_path/Sample.csv'
a = np.loadtxt(path, delimiter=',', encoding='utf-8_sig').flatten()

output.SetDimensions(99, 38, 1)
output.SetOrigin(0.0, 0.0, 0.0)
output.SetSpacing(1, 1, 1)
output.PointData.append(a, 'height')

Here, path is the absolute path to the location of Sample.csv. And set the number of rows and columns in the csv file in output.SetDimensions.

  1. Specify vtkImageData as the Output Data Set Type.

  2. Apply

  3. Continue to apply Filters > Alphabetical > Warp By Scalar, as shown below.

The state file for the above operations is attached.
programmable_source.pvsm (292.2 KB)

3 Likes