# Access point/cell values in Paraview Python scripting

**URL:** https://discourse.paraview.org/t/access-point-cell-values-in-paraview-python-scripting/8420
**Category:** ParaView Support
**Created:** [November 16, 2021, 3:58pm UTC](https://discourse.paraview.org/t/access-point-cell-values-in-paraview-python-scripting/8420 "2021-11-16T15:58:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hohoho](https://discourse.paraview.org/user_avatar/discourse.paraview.org/hohoho/32/7951_2.png) [@hohoho](https://discourse.paraview.org/u/hohoho)
#### Post date: [November 16, 2021, 3:58pm UTC](https://discourse.paraview.org/t/access-point-cell-values-in-paraview-python-scripting/8420/1 "2021-11-16T15:58:15Z")

</div>

I’ve been using the Paraview GUI for some time, I just got started with the Python scripting feature. I want to access point/cell values from Python. The approach I have tried:

```auto
reader = OpenDataFile("/path/to/my/datafile")
tmp = reader.PointData["MyScalarField"]
tmp*2

```

I get: `TypeError: unsupported operand type(s) for *: 'ArrayInformation' and 'int'`  
So the object I stored in tmp is meta-information about the array and not the array itself.

On the other hand, if I do something very similar from the Python calculator interface: `input[0].PointData["MyScalarField"][0]`

, I can access the value of MyScalarField at point #1.

Any reference to resources that might help is welcome, including tutorials. I think I lack vtk knowledge.

PS: I posted the exact same question on stackexchange before realizing there was a better place, I hope that is not a problem.

---

<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: [November 16, 2021, 4:01pm UTC](https://discourse.paraview.org/t/access-point-cell-values-in-paraview-python-scripting/8420/2 "2021-11-16T16:01:14Z")

</div>

You are mixing VTKPython and pvpython, this is possible, but you need to fetch your dataset from the server to the client first.

```auto
reader = OpenDataFile("/path/to/my/datafile")
reader.UpdatePipeline()
dataset = servermanager.Fetch(reader)
dataset.GetPointData().GetArray("MyScalarField")

```

---

<div class="post-metadata">

### Author: ![hohoho](https://discourse.paraview.org/user_avatar/discourse.paraview.org/hohoho/32/7951_2.png) [@hohoho](https://discourse.paraview.org/u/hohoho)
#### Post date: [November 16, 2021, 4:41pm UTC](https://discourse.paraview.org/t/access-point-cell-values-in-paraview-python-scripting/8420/3 "2021-11-16T16:41:48Z")

</div>

Thank you for your answer. For any other beginners out there, the last line results in a vtk data array. To inspect a component of the array, you can call the method GetComponent:

```auto
tmp = dataset.GetPointData().GetArray("MyScalarField") #results in vtk data array
tmp.GetComponent(point_number, 0) #component index is 0 for a scalar array

```

This works for Unstructured Grids, you might get an error at the fetching step for other types of data sets.
