# Extract data from blocks to python efficiently

**URL:** https://discourse.paraview.org/t/extract-data-from-blocks-to-python-efficiently/10467
**Category:** ParaView Support
**Created:** [October 8, 2022, 3:05pm UTC](https://discourse.paraview.org/t/extract-data-from-blocks-to-python-efficiently/10467 "2022-10-08T15:05:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Captain\_Convergence](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/e19b73/32.png) [@Captain\_Convergence](https://discourse.paraview.org/u/Captain_Convergence)
#### Post date: [October 8, 2022, 3:05pm UTC](https://discourse.paraview.org/t/extract-data-from-blocks-to-python-efficiently/10467/1 "2022-10-08T15:05:39Z")

</div>

Dear all,

I need to get the coordinates and velocities vectors for several blocks in my domain for some time snapshots. By now I am looping over each time step and then over each block in order to get the aforementioned values like this:

```auto
# Loop over the blocks
for i in nblocks:
	***Some code here***

	# Loop over the snaps
	for j in range(len(dts_anim)):
	***Some more code here***

		# Allocate lists (vectors)
		X_vect = [None] * npoints
		Y_vect = [None] * npoints
		Z_vect = [None] * npoints
		U_vect = [None] * npoints
		V_vect = [None] * npoints
		W_vect = [None] * npoints		
		
		# Loop over the points of the current block
		data = paraview.servermanager.Fetch(extractBlock)
		block = data.GetBlock(0) 
		for k in range(npoints):
			coors_pnt = block.GetPoint(k)
			X_vect[k] = coors_pnt[0]
			Y_vect[k] = coors_pnt[1]
			Z_vect[k] = coors_pnt[2]
			U_vect[k] = block.GetPointData().GetArray('U').GetValue(k)
			V_vect[k] = block.GetPointData().GetArray('V').GetValue(k)
			W_vect[k] = block.GetPointData().GetArray('W').GetValue(k)

		***The code continues from here***

```

However the loop where i go over the npoints in order to build the \*\_vect lists is extremely slow (). Since I retrieve the data right before the loop like this:

```auto
data = paraview.servermanager.Fetch(extractBlock)
block = data.GetBlock(0)

```

Isn’t it possible to get directly the vectors without looping over all the points? Using **.GetPoint(k)** and **.GetPointData().GetArray('**_').GetValue(k)_\* seems to be quite inefficient.

Thank you in advance!
