| 144 | return group_record(new MedicalRecord(Pattern.compile(",").splitAsStream(replace_csv(record_str)))); |
| 145 | } |
| 146 | public void group_txt(){ |
| 147 | Date d1= new Date(); |
| 148 | // System.out.println(System.getProperty("user.dir")); |
| 149 | String path= System.getProperty("user.dir"); |
| 150 | try { |
| 151 | List<String> result =Files.lines(Paths.get(path,"input.txt")).skip(1).map(Pattern.compile(",")::splitAsStream) |
| 152 | .map(x->group_record(new MedicalRecord(x)).toString()).collect(Collectors.toList()); |
| 153 | // .map(MedicalRecord::new).map(this::group_record).map(GroupResult::toString).collect(Collectors.toList()); |
| 154 | Files.write(Paths.get(path,"output.txt"),result,StandardCharsets.UTF_8,StandardOpenOption.CREATE); |
| 155 | } catch (IOException e) { |
| 156 | System.out.println("读取input.txt失败,请确保文件存在,且内容符合CSV格式,且字段顺序为:Index,gender,age,ageDay,weight,dept,inHospitalTime,leavingType,zdList,ssList"); |
| 157 | e.printStackTrace(); |
| 158 | } |
| 159 | Date d2= new Date(); |
| 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) |