| 204 | System.out.println("group time "+(d2.getTime() - d1.getTime())); |
| 205 | } |
| 206 | public void group_csv(Path filename,List<String> cols){ |
| 207 | Date d1= new Date(); |
| 208 | List<String> result=read_csv(filename,cols) |
| 209 | .parallel() |
| 210 | .map(x->group_record(new MedicalRecord(x)).toCsv()) |
| 211 | // .filter(x->x.record.remark!=null&&!x.record.remark.isEmpty()&&!x.drg.equals(x.record.remark)) |
| 212 | .collect(Collectors.toList()); |
| 213 | Date d2= new Date(); |
| 214 | System.out.println("record count "+result.size()); |
| 215 | System.out.println("group time "+(d2.getTime() - d1.getTime())); |
| 216 | result.add(0, "\uFEFF"+"Index,gender,age,ageDay,weight,dept,inHospitalTime,leavingType,zdList,ssList,amount,remark,status,messages,mdc,adrg,drg"); |
| 217 | try{ |
| 218 | Files.write(Paths.get(filename.toString().replace(".csv", "_java_result.csv")),result,StandardCharsets.UTF_8,StandardOpenOption.CREATE_NEW); |
| 219 | }catch(IOException e) { |
| 220 | System.out.println(String.format("文件写入失败%s", Paths.get(filename.toString().replace(".csv", "_java_result.csv")))); |
| 221 | e.printStackTrace(); |
| 222 | } |
| 223 | } |
| 224 | public static Stream<Object> read_csv(Path filename,List<String> cols){ |
| 225 | try { |
| 226 | List<String> headers=Arrays.asList(Files.lines(filename).findFirst().get().replace( "\uFEFF", "").split(",",-1)); |