Guest User

Untitled

a guest
Feb 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. File outputFile = new File(incoming.toUri());
  2. StringBuilder outputCSV = new StringBuilder();
  3. try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(outputFile))) {
  4. for (RowIterator rowIterator = tradesFromKDB.rowIterator(); rowIterator.hasNext(); count++) {
  5. outputCSV.setLength(0);
  6. row = rowIterator.next();
  7.  
  8. for (String cell : row.toString().split("\|")) {
  9. try {
  10. outputCSV.append(cell.split("=")[1] + ",");
  11. } catch (ArrayIndexOutOfBoundsException e){
  12. // This is a result of the right hand side of an = not having a value
  13. // E.G. |consolidatedflag=|
  14. // In such a case a comma is just appended
  15. outputCSV.append(',');
  16. }
  17. }
  18.  
  19. if( count % 10000 == 0)
  20. logger.info("Processed " + count + " rows.");
  21.  
  22. // Remove the last to characters; the ending '>' and trailing comma
  23. outputCSV.setLength(outputCSV.length() - 2);
  24. outputCSV.append("n");
  25.  
  26. bufferedWriter.write(outputCSV.toString());
  27. }
  28. } catch (IOException e) {
  29. logger.error(e.getMessage());
  30. }
Add Comment
Please, Sign In to add comment