diff --git a/src/main/java/com/huawei/datashow/util/fileUtils/CSVUtil.java b/src/main/java/com/huawei/datashow/util/fileUtils/CSVUtil.java index 4c72c6ee6a923f4f801fdd869cd76f53b1f2d56b..fc9d877a1be149846d3997bd69a569864d08a6b3 100644 --- a/src/main/java/com/huawei/datashow/util/fileUtils/CSVUtil.java +++ b/src/main/java/com/huawei/datashow/util/fileUtils/CSVUtil.java @@ -90,30 +90,33 @@ public class CSVUtil { List csvRecords = parser.getRecords(); List list = new ArrayList<>(); - for (int i = startIndex; i < limit + startIndex; i++) { - if (i == rowCount) { - break; - } - - Map map = JSON.parseObject(csvRecords.get(i).get(0), LinkedHashMap.class); + if (limit > 0) { + for (int i = startIndex; i < limit + startIndex; i++) { + if (i == rowCount) { + break; + } - for (String columnName : deleteColumnName) { - map.remove(columnName); - } + Map map = JSON.parseObject(csvRecords.get(i).get(0), LinkedHashMap.class); - if (mode == 0) { - if (deleteRowIndex.contains(i)) { - map.clear(); + for (String columnName : deleteColumnName) { + map.remove(columnName); } - list.add(map); - } else if (mode == 1) { - if (!deleteRowIndex.contains(i)) { + if (mode == 0) { + if (deleteRowIndex.contains(i)) { + map.clear(); + } list.add(map); + + } else if (mode == 1) { + if (!deleteRowIndex.contains(i)) { + list.add(map); + } } - } + } } + Map result = new LinkedHashMap<>(); result.put("sourceData", list); if (csvRecords.size() > 0) {