# Getting the total number of blocks

**URL:** https://discourse.paraview.org/t/getting-the-total-number-of-blocks/10517
**Category:** ParaView Support
**Tags:** python
**Created:** [October 14, 2022, 9:51am UTC](https://discourse.paraview.org/t/getting-the-total-number-of-blocks/10517 "2022-10-14T09:51:06Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Echo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@Echo](https://discourse.paraview.org/u/Echo)
#### Post date: [October 14, 2022, 9:51am UTC](https://discourse.paraview.org/t/getting-the-total-number-of-blocks/10517/1 "2022-10-14T09:51:06Z")

</div>

Hello All,

I want to know how to get` the total number of blocks` in my file (in Exodus format) by using python .

Thank you in advance.

---

<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: [October 17, 2022, 1:51am UTC](https://discourse.paraview.org/t/getting-the-total-number-of-blocks/10517/2 "2022-10-17T01:51:48Z")

</div>

Hi @Echo

`GetActiveSource().GetDataInformation().DataInformation.GetNumberOfDataSets()`

Best,

---

<div class="post-metadata">

### Author: ![Echo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@Echo](https://discourse.paraview.org/u/Echo)
#### Post date: [October 17, 2022, 3:25am UTC](https://discourse.paraview.org/t/getting-the-total-number-of-blocks/10517/3 "2022-10-17T03:25:30Z")

</div>

Thanks you very much! @mwestphal

Another question: I notice that when i open my file in GUI, the ‘trace’ of the python script in paraview automatically shows the following form:

```auto
File= IOSSReader(registrationName=File, FileName=filePath)
File.ElementBlocks = ['block_1', 'block_2', 'block_6', 'block_7', 'block_11', 'block_12', 'block_16']
File.NodeBlockFields = ['disp', 'temp']
File.ElementBlockFields = ['vonmises']
File.NodeSets = []
File.SideSets = []

```

Based on my understanding, first line represents opening the file, and the second line represents selecting the blocks.  
However, if there are a large number of blocks and i want to write the python script by myself to open the file and selecting all blocks, it could be annoying to write all block names one by one.  
Is there any command i can use to import my file and selcting all blocks more simply?

---

<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: [October 17, 2022, 3:26am UTC](https://discourse.paraview.org/t/getting-the-total-number-of-blocks/10517/4 "2022-10-17T03:26:45Z")

</div>

```auto
File.ElementBlocks.SelectAll()

```

---

<div class="post-metadata">

### Author: ![Echo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@Echo](https://discourse.paraview.org/u/Echo)
#### Post date: [October 17, 2022, 3:40am UTC](https://discourse.paraview.org/t/getting-the-total-number-of-blocks/10517/5 "2022-10-17T03:40:26Z")

</div>

@mwestphal  
Thanks a lot for your reply. I am new to Paraview, i want to know where i can find these valid commands and their usages. I searched _the Paraview Tutorial_, but it seems only a few available python commands are introduced.

---

<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: [October 17, 2022, 3:42am UTC](https://discourse.paraview.org/t/getting-the-total-number-of-blocks/10517/6 "2022-10-17T03:42:04Z")

</div>

[https://kitware.github.io/paraview-docs/latest/python/](https://kitware.github.io/paraview-docs/latest/python/)

Also, in the Python Shell, if you press Tab, you get an autocompletion menu.

---

<div class="post-metadata">

### Author: ![Echo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/e/c6cbf5/32.png) [@Echo](https://discourse.paraview.org/u/Echo)
#### Post date: [October 17, 2022, 3:45am UTC](https://discourse.paraview.org/t/getting-the-total-number-of-blocks/10517/7 "2022-10-17T03:45:49Z")

</div>

@mwestphal Thanks very much for you kindly and patiently help! 😃
