Guest User

Untitled

a guest
Oct 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. Sector,Total Number of Occurrence
  2. sector1,12
  3. sector2,30
  4. sector3,100
  5.  
  6. House,Total Number of Occurrence
  7. B12,80
  8. A2,87
  9.  
  10. Sector,Total Number of Occurrence
  11. sector 99,89
  12. sector 11,9
  13.  
  14. House,Total Number of Occurrence
  15. Q11,22
  16. Q22,67
  17.  
  18. Sector,Total Number of Occurrence
  19. sector1,12
  20. sector2,30
  21. sector3,100
  22. sector 99,89
  23. sector 11,9
  24.  
  25. House,Total Number of Occurrence
  26. B12,80
  27. A2,87
  28. Q11,22
  29. Q22,67
  30.  
  31. Sector,Total Number of Occurrence
  32. sector1,12
  33. sector2,30
  34. sector3,100
  35.  
  36. House,Total Number of Occurrence
  37. B12,80
  38. A2,87
  39. sector 99,89
  40. sector 11,9
  41.  
  42. House,Total Number of Occurrence
  43. B12,80
  44. A2,87
  45.  
  46. import java.io.BufferedReader;
  47. import java.io.FileNotFoundException;
  48. import java.io.FileReader;
  49. import java.io.IOException;
  50. import java.nio.charset.Charset;
  51. import java.nio.file.Files;
  52. import java.nio.file.Path;
  53. import java.nio.file.Paths;
  54. import java.util.ArrayList;
  55. import java.util.Arrays;
  56. import java.util.List;
  57.  
  58. public class SummarizeReport1
  59. {
  60. static ArrayList<String> list1 = new ArrayList<>();
  61. static String line1;
  62. public static void main(String[] args) throws IOException
  63. {
  64. List<Path> paths = Arrays.asList(Paths.get("C:\Users\user\Desktop\Axway email\log\backup\report12017-10-31.csv"), Paths.get("C:\Users\user\Desktop\Axway email\log\backup\report12017-10-31 - Copy.csv"));
  65. List<String> mergedLines = getMergedLines(paths);
  66. Path target = Paths.get("C:\Users\user\Desktop\Axway email\log\backup\SummarizedReport1.csv");
  67. Files.write(target, mergedLines, Charset.forName("UTF-8"));
  68. }
  69.  
  70. private static List<String> getMergedLines(List<Path> paths) throws IOException
  71. {
  72. List<String> mergedLines = new ArrayList<> ();
  73. for (Path p : paths)
  74. {
  75. List<String> lines = Files.readAllLines(p, Charset.forName("UTF-8"));
  76. if (!lines.isEmpty()) {
  77. if (mergedLines.isEmpty()) {
  78. mergedLines.add(lines.get(0)); //add header only once
  79. }
  80. mergedLines.addAll(lines.subList(1, lines.size()));
  81. }
  82. }
  83. return mergedLines;
  84. }
  85. }
Add Comment
Please, Sign In to add comment