# Create a reader plugin to read multiple files into one vtkMultiBlockDataSet

**URL:** https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895
**Category:** Development
**Created:** [May 21, 2019, 12:07pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895 "2019-05-21T12:07:06Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 21, 2019, 12:07pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/1 "2019-05-21T12:07:06Z")

</div>

Dear Experts,  
Is it possible to write a reader plugin that can read multiple files’ content into one vtkMultiBlockDataSet?

In my situation, the data in each file is just a small block of the whole data, so i need to read them into one vtkMultiBlockDataSet then user selected all the files from UI.

Then in the pipeline browser view, all the file blocks will have the same parent

Any suggestion how to do this?

Thanks and Best Regards,

Sharon

---

<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: [May 21, 2019, 12:13pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/2 "2019-05-21T12:13:55Z")

</div>

You can’t create a reader that will output a single multiblockdataset and at the same time, have an item in the pipeline browser for each block.  
But take a look into the Multiblock inspector instead (View -\> MultiblockInspector)

Other then that, it is definitelly possible to a plugin that expose a reader that read multiples files into one vtkMultiBlockDataSet.

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 21, 2019, 12:21pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/3 "2019-05-21T12:21:16Z")

</div>

Thank you Mathieu!  
I tried GroupDatasets filter, it works.  
However, if i load 2 files, after this filter, there will be 3 groupDataSets and the last one is the one that contain all the blocks.

I expected result is only one groupDataSet, and its children under it, just like a tree view

Thank you!

Best Regards,  
Sharon

---

<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: [May 21, 2019, 12:23pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/4 "2019-05-21T12:23:47Z")

</div>

If you implement your own filter, you have a full freedom on how the block are organized.

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 21, 2019, 12:24pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/5 "2019-05-21T12:24:08Z")

</div>

> [@mwestphal](#):
>
> a reader that read multiples files into one vtkMultiBlockDataSet

How to implement this? i found the pipeline already hard code one reader can only receive one file name…

---

<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: [May 21, 2019, 12:24pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/6 "2019-05-21T12:24:56Z")

</div>

A reader can receive a directory name.

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 21, 2019, 12:25pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/7 "2019-05-21T12:25:00Z")

</div>

Thank you Mathieu!

I will have a try for this!

Best Regards

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 21, 2019, 12:30pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/8 "2019-05-21T12:30:35Z")

</div>

You mean I can read all the files under the same directory when user choose one file?

I am confused when user choose a directory, how can paraview know which reader to use?

And if i write my own reader, how can tell paraview to use my reader after user select certain directory?

Because for a file, there is a suffix to tell reader, but for a directory, how to know?

---

<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: [May 21, 2019, 12:36pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/9 "2019-05-21T12:36:47Z")

</div>

> [@sharon](#):
>
> You mean I can read all the files under the same directory when user choose one file?

Yes

> [@](#):
>
> I am confused when user choose a directory, how can paraview know which reader to use?
> 
> And if i write my own reader, how can tell paraview to use my reader after user select certain directory?
> 
> Because for a file, there is a suffix to tell reader, but for a directory, how to know?

There is a pattern mechanism in the XML definition of the reader, see AMReX Particles Reader in readers.xml

---

<div class="post-metadata">

### Author: ![sharon](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/67e7ee/32.png) [@sharon](https://discourse.paraview.org/u/sharon)
#### Post date: [May 21, 2019, 12:39pm UTC](https://discourse.paraview.org/t/create-a-reader-plugin-to-read-multiple-files-into-one-vtkmultiblockdataset/1895/10 "2019-05-21T12:39:40Z")

</div>

Yes, I just tried to open a directory and found the reader you mentioned is appeared on the UI.  
OK, I will take a look at it!

Big Thank You to you, Mathieu!

You really give me some ideas!

very Best Regards to you,  
Sharon
