Hi guys, wondering if anyone could help with have a question about this parser API doc
My code has TWO for-each loops which should both iterate through the CSVRecord(s) contained within the CSV Parser object. However, it will only execute the FIRST of the for-each loops (regardless of which I put first). I don't know why ??
Because, I imagine, that the iterator that's created on the first for-each is actually operating by doing a line-by-line read of the input file. Creating a second iterator doesn't rewind the file (not all input source can be rewound, in fact). so you get an instant end-of-data and an apparent "no-op".
If you want to parse over the same data multiple times, have it decant the input file into memory. See the API section titled "Parsing into memory". That will construct a List which may be iterated as many times as you like - even in parallel, if you like.
Sometimes the only way things ever got fixed is because people became uncomfortable.