Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sector,Total Number of Occurrence
- sector1,12
- sector2,30
- sector3,100
- House,Total Number of Occurrence
- B12,80
- A2,87
- Sector,Total Number of Occurrence
- sector 99,89
- sector 11,9
- House,Total Number of Occurrence
- Q11,22
- Q22,67
- Sector,Total Number of Occurrence
- sector1,12
- sector2,30
- sector3,100
- sector 99,89
- sector 11,9
- House,Total Number of Occurrence
- B12,80
- A2,87
- Q11,22
- Q22,67
- Sector,Total Number of Occurrence
- sector1,12
- sector2,30
- sector3,100
- House,Total Number of Occurrence
- B12,80
- A2,87
- sector 99,89
- sector 11,9
- House,Total Number of Occurrence
- B12,80
- A2,87
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.nio.charset.Charset;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.nio.file.Paths;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- public class SummarizeReport1
- {
- static ArrayList<String> list1 = new ArrayList<>();
- static String line1;
- public static void main(String[] args) throws IOException
- {
- 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"));
- List<String> mergedLines = getMergedLines(paths);
- Path target = Paths.get("C:\Users\user\Desktop\Axway email\log\backup\SummarizedReport1.csv");
- Files.write(target, mergedLines, Charset.forName("UTF-8"));
- }
- private static List<String> getMergedLines(List<Path> paths) throws IOException
- {
- List<String> mergedLines = new ArrayList<> ();
- for (Path p : paths)
- {
- List<String> lines = Files.readAllLines(p, Charset.forName("UTF-8"));
- if (!lines.isEmpty()) {
- if (mergedLines.isEmpty()) {
- mergedLines.add(lines.get(0)); //add header only once
- }
- mergedLines.addAll(lines.subList(1, lines.size()));
- }
- }
- return mergedLines;
- }
- }
Add Comment
Please, Sign In to add comment