|
@@ -44,15 +44,27 @@ public class DataExtractTest {
|
|
//public static final String appId = "9da5da63-29a1-4c59-ad0b-f1f3c737924a";
|
|
//public static final String appId = "9da5da63-29a1-4c59-ad0b-f1f3c737924a";
|
|
|
|
|
|
//public static final String inputDirectoryPath = "E:\\project\\vscode\\《急诊与灾难医学(第4版)》\\第二章急性发热\\"; // 修改为目录路径
|
|
//public static final String inputDirectoryPath = "E:\\project\\vscode\\《急诊与灾难医学(第4版)》\\第二章急性发热\\"; // 修改为目录路径
|
|
- public static final String inputDirectoryPath = "E:\\project\\vscode\\《急诊与灾难医学(第4版)》\\第五章心悸与心律失常\\"; // 修改为目录路径
|
|
|
|
|
|
+ static List<String> fileNameList = new ArrayList<>();
|
|
|
|
+ static {
|
|
|
|
+ fileNameList.add("第十二章环境及理化因素损伤");
|
|
|
|
+ fileNameList.add("第十三章急性感染");
|
|
|
|
+ fileNameList.add("第十四章多器官功能障碍综合征");
|
|
|
|
+ fileNameList.add("第十五章心肺脑复苏");
|
|
|
|
+ }
|
|
|
|
+ public static String inputDirectoryPath = "/Users/ycw/work/邵逸夫急诊科审核通过数据/files/《急诊与灾难医学(第4版)》/"; // 修改为目录路径
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
-
|
|
|
|
//String inputDirectoryPath = "E:\\project\\vscode\\《急诊与灾难医学(第4版)》\\"; // 修改为目录路径
|
|
//String inputDirectoryPath = "E:\\project\\vscode\\《急诊与灾难医学(第4版)》\\"; // 修改为目录路径
|
|
- File inputDirectory = new File(inputDirectoryPath);
|
|
|
|
- // 无子目录时处理txt文件
|
|
|
|
- workbook = new HSSFWorkbook();//这里也可以设置sheet的Name
|
|
|
|
- sheet = workbook.createSheet();
|
|
|
|
- traverse(inputDirectory);
|
|
|
|
|
|
+ String baseInputDirectoryPath = inputDirectoryPath;
|
|
|
|
+ for (String fileName : fileNameList) {
|
|
|
|
+ inputDirectoryPath = baseInputDirectoryPath + fileName;
|
|
|
|
+ File inputDirectory = new File(inputDirectoryPath);
|
|
|
|
+ // 无子目录时处理txt文件
|
|
|
|
+ workbook = new HSSFWorkbook();//这里也可以设置sheet的Name
|
|
|
|
+ sheet = workbook.createSheet();
|
|
|
|
+ rows = 0; // 重置行号
|
|
|
|
+ traverse(inputDirectory);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
static HSSFWorkbook workbook;
|
|
static HSSFWorkbook workbook;
|
|
static HSSFSheet sheet = null;
|
|
static HSSFSheet sheet = null;
|
|
@@ -85,7 +97,7 @@ public class DataExtractTest {
|
|
if (file.getName().toLowerCase().endsWith(".txt") && file.getName().toLowerCase().contains("_split_")) {
|
|
if (file.getName().toLowerCase().endsWith(".txt") && file.getName().toLowerCase().contains("_split_")) {
|
|
//System.out.println("发现文本文件: " + file.getName());
|
|
//System.out.println("发现文本文件: " + file.getName());
|
|
String inputFilePath = file.getAbsolutePath();
|
|
String inputFilePath = file.getAbsolutePath();
|
|
- inputFilePath = inputFilePath.replace("E:\\project\\vscode", "");
|
|
|
|
|
|
+ inputFilePath = inputFilePath.replace("/Users/ycw/work/邵逸夫急诊科审核通过数据/files", "");
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
|
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
|
String line;
|
|
String line;
|
|
@@ -102,7 +114,7 @@ public class DataExtractTest {
|
|
HSSFRow row = sheet.createRow(rows++);
|
|
HSSFRow row = sheet.createRow(rows++);
|
|
row.createCell(0).setCellValue(response == null ? "" : JSONObject.parseObject(response).getString("answer"));
|
|
row.createCell(0).setCellValue(response == null ? "" : JSONObject.parseObject(response).getString("answer"));
|
|
row.createCell(1).setCellValue(sb.toString());
|
|
row.createCell(1).setCellValue(sb.toString());
|
|
- row.createCell(2).setCellValue(inputFilePath);
|
|
|
|
|
|
+ row.createCell(2).setCellValue(inputFilePath.replace("/","\\"));
|
|
save(FileCommonUtils.getFileNameWithoutExtension(inputDirectoryPath));
|
|
save(FileCommonUtils.getFileNameWithoutExtension(inputDirectoryPath));
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -114,7 +126,7 @@ public class DataExtractTest {
|
|
|
|
|
|
private static synchronized void save(String fileName) {
|
|
private static synchronized void save(String fileName) {
|
|
try {
|
|
try {
|
|
- fileName="C:\\Users\\17664\\Desktop\\"+fileName+".xlsx";
|
|
|
|
|
|
+ fileName="/Users/ycw/work/邵逸夫急诊科审核通过数据/"+fileName+".xlsx";
|
|
//文档输出
|
|
//文档输出
|
|
FileOutputStream out = new FileOutputStream(new File(fileName));
|
|
FileOutputStream out = new FileOutputStream(new File(fileName));
|
|
workbook.write(out);
|
|
workbook.write(out);
|