| 160 | System.out.println("group time "+(d2.getTime() - d1.getTime())); |
| 161 | } |
| 162 | public void group_csv(Path filename,List<String> cols){ |
| 163 | Date d1= new Date(); |
| 164 | List<String> result=read_csv(filename,cols) |
| 165 | .parallel() |
| 166 | .map(x->group_record(new MedicalRecord(x)).toCsv()) |
| 167 | // .filter(x->x.record.remark!=null&&!x.record.remark.isEmpty()&&!x.drg.equals(x.record.remark)) |
| 168 | .collect(Collectors.toList()); |
| 169 | Date d2= new Date(); |
| 170 | System.out.println("record count "+result.size()); |
| 171 | System.out.println("group time "+(d2.getTime() - d1.getTime())); |
| 172 | result.add(0, "\uFEFF"+"Index,gender,age,ageDay,weight,dept,inHospitalTime,leavingType,zdList,ssList,remark,status,messages,mdc,adrg,drg"); |
| 173 | try{ |
| 174 | Files.write(Paths.get(filename.toString().replace(".csv", "_java_result.csv")),result,StandardCharsets.UTF_8,StandardOpenOption.CREATE_NEW); |
| 175 | }catch(IOException e) { |
| 176 | System.out.println(String.format("文件写入失败%s", Paths.get(filename.toString().replace(".csv", "_java_result.csv")))); |
| 177 | e.printStackTrace(); |
| 178 | } |
| 179 | } |
| 180 | public static Stream<Object> read_csv(Path filename,List<String> cols){ |
| 181 | try { |
| 182 | List<String> headers=Arrays.asList(Files.lines(filename).findFirst().get().replace( "\uFEFF", "").split(",",-1)); |