# CSV table data to 3D

**URL:** https://discourse.paraview.org/t/csv-table-data-to-3d/7858
**Category:** ParaView Support
**Created:** [August 24, 2021, 6:39am UTC](https://discourse.paraview.org/t/csv-table-data-to-3d/7858 "2021-08-24T06:39:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Eyang](https://discourse.paraview.org/user_avatar/discourse.paraview.org/eyang/32/7426_2.png) [@Eyang](https://discourse.paraview.org/u/Eyang)
#### Post date: [August 24, 2021, 6:39am UTC](https://discourse.paraview.org/t/csv-table-data-to-3d/7858/1 "2021-08-24T06:39:58Z")

</div>

I’m new to Paraview. I have CSV data in table format. So the rows represent Y, and the columns represent X, and for each cell, the Z value is stored. Can I use Paraview to generate the 3D view?  
for example, as below, ABCDEFG are columns representing X, and 12345 in the left are rows representing Y. The numbers indicate the Z value.  
/t A B C D E F G  
1 2 2 3 3 4 4 4  
2 1 1 2 2 3 4 5  
3 2 2 3 3 5 5 5  
4 2 2 22 2 3 4 5  
5 4 5 5 5 5 5 5

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 24, 2021, 8:08am UTC](https://discourse.paraview.org/t/csv-table-data-to-3d/7858/2 "2021-08-24T08:08:54Z")

</div>

CSVReader + TableToStructuredGrid should work

---

<div class="post-metadata">

### Author: ![Eyang](https://discourse.paraview.org/user_avatar/discourse.paraview.org/eyang/32/7426_2.png) [@Eyang](https://discourse.paraview.org/u/Eyang)
#### Post date: [August 27, 2021, 4:14am UTC](https://discourse.paraview.org/t/csv-table-data-to-3d/7858/3 "2021-08-27T04:14:51Z")

</div>

Uploading: eye height high mag.csv…  
[Sample.csv](https://discourse.paraview.org/uploads/short-url/l22098qup8Dm8kfkMmcUig3dos4.csv) (21.8 KB)

Hi Mat, thanks for the reply. I’ve attached a sample file. The file is not structured as XYZ columns. The columns, A, B,C,D …represent X-axis (they are in arbitrary units), and rows 1,2,…38 represent Y-axis (with arbitrary units), and each cell value represents the Z value (hight). I’m having trouble reading this with Paraview. I’d like to display 3D structure but not sure how. Thanks.

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [August 27, 2021, 8:25am UTC](https://discourse.paraview.org/t/csv-table-data-to-3d/7858/4 "2021-08-27T08:25:33Z")

</div>

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.

```python
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**.

```python
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.

 ![programmable_source](https://discourse.paraview.org/uploads/default/original/2X/2/2cf966a87a4fa4abed9c9bed25c6233314c2da75.png)

The state file for the above operations is attached.  
[programmable\_source.pvsm](https://discourse.paraview.org/uploads/short-url/gg2hG5vDC3seZF29CLlb9dMBjLS.pvsm) (292.2 KB)

---

<div class="post-metadata">

### Author: ![Eyang](https://discourse.paraview.org/user_avatar/discourse.paraview.org/eyang/32/7426_2.png) [@Eyang](https://discourse.paraview.org/u/Eyang)
#### Post date: [September 4, 2021, 5:30am UTC](https://discourse.paraview.org/t/csv-table-data-to-3d/7858/5 "2021-09-04T05:30:48Z")

</div>

Thank you for the very detailed reply. I’ll give it a try. Much appreciated.
