Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File outputFile = new File(incoming.toUri());
- StringBuilder outputCSV = new StringBuilder();
- try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(outputFile))) {
- for (RowIterator rowIterator = tradesFromKDB.rowIterator(); rowIterator.hasNext(); count++) {
- outputCSV.setLength(0);
- row = rowIterator.next();
- for (String cell : row.toString().split("\|")) {
- try {
- outputCSV.append(cell.split("=")[1] + ",");
- } catch (ArrayIndexOutOfBoundsException e){
- // This is a result of the right hand side of an = not having a value
- // E.G. |consolidatedflag=|
- // In such a case a comma is just appended
- outputCSV.append(',');
- }
- }
- if( count % 10000 == 0)
- logger.info("Processed " + count + " rows.");
- // Remove the last to characters; the ending '>' and trailing comma
- outputCSV.setLength(outputCSV.length() - 2);
- outputCSV.append("n");
- bufferedWriter.write(outputCSV.toString());
- }
- } catch (IOException e) {
- logger.error(e.getMessage());
- }
Add Comment
Please, Sign In to add comment