diff --git a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlDDLProvider.java b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlDDLProvider.java index 019da6d96e..259169b614 100644 --- a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlDDLProvider.java +++ b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlDDLProvider.java @@ -56,11 +56,7 @@ public class MysqlDDLProvider extends DDLProviderImpl { Integer size = datasetTableField.getSize() * 4; switch (datasetTableField.getDeExtractType()) { case 0: - if (size < 65533) { - Column_Fields.append("varchar(length)".replace("length", String.valueOf(datasetTableField.getSize()))).append(",`"); - }else { - Column_Fields.append("longtext").append(",`"); - } + Column_Fields.append("longtext").append(",`"); break; case 1: size = size < 50? 50 : size; diff --git a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java index e539ae10c8..9e2982175b 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -741,6 +741,33 @@ public class ExtractDataService { totalSheets = excelXlsxReader.totalSheets; } + if (StringUtils.equalsIgnoreCase(suffix, "csv")) { + List fields = new ArrayList<>(); + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(excelSheetData.getPath()), StandardCharsets.UTF_8)); + String s = reader.readLine();// first line + String[] split = s.split(","); + for (String s1 : split) { + TableField tableFiled = new TableField(); + tableFiled.setFieldName(s1); + tableFiled.setRemarks(s1); + tableFiled.setFieldType("TEXT"); + fields.add(tableFiled); + } + List> csvData = new ArrayList<>(); + String line; + while ((line = reader.readLine()) != null) { + csvData.add(Arrays.asList(line.split(","))); + } + ExcelSheetData csvSheetData = new ExcelSheetData(); + String[] fieldArray = fields.stream().map(TableField::getFieldName).toArray(String[]::new); + csvSheetData.setFields(fields); + csvSheetData.setData(csvData); + csvSheetData.setExcelLabel(excelSheetData.getExcelLabel()); + csvSheetData.setFieldsMd5(Md5Utils.md5(StringUtils.join(fieldArray, ","))); + totalSheets = Arrays.asList(csvSheetData); + } + + for (ExcelSheetData sheet : totalSheets) { if (sheet.getExcelLabel().equalsIgnoreCase(excelSheetData.getExcelLabel())) { for (List dataItem : sheet.getData()) {