How to fix problems with DataSetIterators?

Hello,
I have two CSV files, one for training data and one for testing data. My goal is to do a time series prediction on stock data. The training data consists of 80% of stocks data over the last 5 years, and the test data consists of the most recent 20% of its data. I create two CSVSequenceRecordReaders and load a file into each separate reader, then with each separate reader, I create a DataSetIterator. Everything up to that point works, except I want to create DataSets with both the TestDataSetIterator and TrainDatasetIterator. When I call the next() method from each iterator, I get NoSuchElementException error. How can I fix my DataSetIterators so that I can properly convert them into DataSet Objects?

Here is the example I am following: https://github.com/deeplearning4j/oreilly-book-dl4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/recurrent/regression/SingleTimestepRegressionExample.java

When i get to around line 68, creating a DataSet object from DataSetIterator.next() does not work for either DataSetIterators. I get the error i mentioned above.

Did the other example I sent help you at all?

yes, it did. Ive actually solved the DataSetIterator problem. Does it make a difference if i train my network on a DataSet Object rather than a DataSetIterator Object?

You could create differences because of a user error but it should be the same result if done correctly.