Source:
<code>private static List<String> prepareTrainAndTest(int trainSize, int testSize, int numberOfTimesteps) throws IOException { Path rawPath = Paths.get(baseDir.getAbsolutePath() + "/passengers_raw.csv"); List<String> rawStrings = Files.readAllLines(rawPath, Charset.defaultCharset()); setNumOfVariables(rawStrings); FileUtils.cleanDirectory(featuresDirTrain); FileUtils.cleanDirectory(labelsDirTrain); FileUtils.cleanDirectory(featuresDirTest); FileUtils.cleanDirectory(labelsDirTest); for (int i = 0; i < trainSize; i++) { Path featuresPath = Paths.get(featuresDirTrain.getAbsolutePath() + "/train_" + i + ".csv"); Path labelsPath = Paths.get(labelsDirTrain + "/train_" + i + ".csv"); for (int j = 0; j < numberOfTimesteps; j++) { Files.write(featuresPath, rawStrings.get(i + j).concat(System.lineSeparator()).getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); } <START> Files.write(labelsPath, rawStrings.get(i + numberOfTimesteps).concat(System.lineSeparator()).getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); <END> } for (int i = trainSize; i < testSize + trainSize; i++) { Path featuresPath = Paths.get(featuresDirTest + "/test_" + i + ".csv"); Path labelsPath = Paths.get(labelsDirTest + "/test_" + i + ".csv"); int j; for (j = 0; j < numberOfTimesteps; j++) { Files.write(featuresPath, rawStrings.get(i + j).concat(System.lineSeparator()).getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); } Files.write(labelsPath, rawStrings.get(i + j).concat(System.lineSeparator()).getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); } return rawStrings; }</code><technical_language>Thx</technical_language>

Target:
private static List<String> prepareTrainAndTest(int trainSize, int testSize, int numberOfTimesteps) throws IOException { Path rawPath = Paths.get(baseDir.getAbsolutePath() + "/passengers_raw.csv"); List<String> rawStrings = Files.readAllLines(rawPath, Charset.defaultCharset()); setNumOfVariables(rawStrings); FileUtils.cleanDirectory(featuresDirTrain); FileUtils.cleanDirectory(labelsDirTrain); FileUtils.cleanDirectory(featuresDirTest); FileUtils.cleanDirectory(labelsDirTest); for (int i = 0; i < trainSize; i++) { Path featuresPath = Paths.get(featuresDirTrain.getAbsolutePath() + "/train_" + i + ".csv"); Path labelsPath = Paths.get(labelsDirTrain + "/train_" + i + ".csv"); for (int j = 0; j < numberOfTimesteps; j++) { Files.write(featuresPath, rawStrings.get(i + j).concat(System.lineSeparator()).getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); } Files.write(labelsPath, rawStrings.get(i + numberOfTimesteps).concat(System.lineSeparator()).getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); } for (int i = trainSize; i < testSize + trainSize; i++) { Path featuresPath = Paths.get(featuresDirTest + "/test_" + i + ".csv"); Path labelsPath = Paths.get(labelsDirTest + "/test_" + i + ".csv"); for (int j = 0; j < numberOfTimesteps; j++) { Files.write(featuresPath, rawStrings.get(i + j).concat(System.lineSeparator()).getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); } Files.write(labelsPath, rawStrings.get(i + numberOfTimesteps).concat(System.lineSeparator()).getBytes(), StandardOpenOption.APPEND, StandardOpenOption.CREATE); } return rawStrings; }