# Dynamic number of partitions

**URL:** <https://forum.cloverdx.com/t/dynamic-number-of-partitions/1834>\
**Category:** CloverDX Platform\
**Created:** [February 21, 2017, 12:00am UTC](https://forum.cloverdx.com/t/dynamic-number-of-partitions/1834 "2017-02-21T00:00:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anyeone](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@anyeone](https://forum.cloverdx.com/u/anyeone)\
**Post date:** [February 21, 2017, 12:00am UTC](https://forum.cloverdx.com/t/dynamic-number-of-partitions/1834/1 "2017-02-21T00:00:00Z")

</div>

Greetings,

I am looking to split a very large XML file for which I’ve already parsed the data individual records of three different types.  
I want to split each of those three sets of records into a dynamic number of chunks so as to only have (for example) 1000 records in each chunk. I won’t have any idea how many records are in the original files though, so I would have to calculate the number of chunks dynamically. The Partition component doesn’t appear to let me chunk based on # of records, just on a range of values or a particular partition key, neither of which works for this scenario.

Additionally, if I don’t know how many output ports there will be, how do I bind the output to a writer?

Thanks in advance,  
Anye

---

<div class="post-metadata">

**Author:** ![krizovav](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@krizovav](https://forum.cloverdx.com/u/krizovav)\
**Post date:** [February 23, 2017, 8:06am UTC](https://forum.cloverdx.com/t/dynamic-number-of-partitions/1834/2 "2017-02-23T08:06:07Z")

</div>

Hi Anye,

The use case you are describing should be solved by the attribute „Records per file“, which is available in some writers. If you would like to read more about this attribute, you can look into documentation [here](http://doc.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/partitioning-output-into-different-output-files.html).

I hope this helps.

Regards,

---

<div class="post-metadata">

**Author:** ![svecp](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@svecp](https://forum.cloverdx.com/u/svecp)\
**Post date:** [February 23, 2017, 2:01pm UTC](https://forum.cloverdx.com/t/dynamic-number-of-partitions/1834/3 "2017-02-23T14:01:16Z")

</div>

Hi Anye,

Vladka is right. You can use “Records per file”, just make sure you also include a placeholder $ somewhere in the File URL attribute, otherwise you’ll be overwriting the same file over and over again.

Bits and pieces from online documentation on the subject:  
[http://doc.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/partitioning-output-into-different-output-files.html](http://doc.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/partitioning-output-into-different-output-files.html).

---

<div class="post-metadata">

**Author:** ![anyeone](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@anyeone](https://forum.cloverdx.com/u/anyeone)\
**Post date:** [February 23, 2017, 3:30pm UTC](https://forum.cloverdx.com/t/dynamic-number-of-partitions/1834/4 "2017-02-23T15:30:45Z")

</div>

Perfect! Thanks, gentlemen!
