# Split dataset Iterator

**URL:** <https://community.konduit.ai/t/split-dataset-iterator/755>\
**Category:** DL4J\
**Created:** [July 28, 2020, 6:32pm UTC](https://community.konduit.ai/t/split-dataset-iterator/755 "2020-07-28T18:32:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cagneymoreau](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/cagneymoreau/32/296_2.png) [@cagneymoreau](https://community.konduit.ai/u/cagneymoreau)\
**Post date:** [July 28, 2020, 6:32pm UTC](https://community.konduit.ai/t/split-dataset-iterator/755/1 "2020-07-28T18:32:09Z")

</div>

I wanted a way to split a datasetIterator and couldn’t find it. Did I miss something? Based on my understanding this is assumed to be done earlier in pipeline so its not possible with api.

Any thoughts on my approach below? I implemented a dataset iterator but only return a partial dataset. This cuts off the last portion of my sequence data. Si the iterator returns every file but each file si split but some double.

If I wanted to perform a regular file split I suppose I would have to create a similar wrapper and change the reset functionality to only iterate through a portion. As I see it there is no way to reach the iterators recordreaderlist and change the file list itself.

```
public class SplitIterator implements DataSetIterator {

    private double split; //what percent of data is for training only
    boolean training;
    DataSetIterator iterator;

    public SplitIterator(DataSetIterator iter, double split, boolean training)
    {
        iterator = iter;
        this.split = split;
        this.training = training;

    }

    //the normal next method are colld in training so send out training dataset here
    @Override
    public boolean hasNext() {
     return iterator.hasNext();
    }

    @Override
    public DataSet next() {
        if (training){
            return FormattedDataRequester.splitDataSet(iterator.next(), split).get(0);
        }else{
            return FormattedDataRequester.splitDataSet(iterator.next(), split).get(1);
        }

    }

    @Override
    public void reset() {
        iterator.reset();

    }

```
