kotlin-csv
kotlin-csv copied to clipboard
Exception in thread "main" com.github.doyaaaaaken.kotlincsv.util.CSVParseFormatException: must appear escapeChar(") after escapeChar(") [rowNum = 729, colIndex = 467, char = "]
I am using this method to convert from csv to xlsx
fun convertCsvToXlsx(file: File): File {
val csvFileName = file.nameWithoutExtension
val xlsxFile = File("${file.parent}/$csvFileName+1.xlsx")
val csvData = mutableListOf<List<String>>()
CsvReader().open(file) {
readAllAsSequence().forEach { row ->
csvData.add(row)
}
}
val workbook = XSSFWorkbook()
val sheet = workbook.createSheet("Sheet1")
for ((rowIndex, rowData) in csvData.withIndex()) {
val row = sheet.createRow(rowIndex)
for ((columnIndex, cellData) in rowData.withIndex()) {
val cell = row.createCell(columnIndex, CellType.STRING)
cell.setCellValue(cellData)
}
}
FileOutputStream(xlsxFile).use { fileOutputStream ->
workbook.write(fileOutputStream)
}
return xlsxFile
}
This error in the title is thrown and I cant figure out why. The csv file I am trying to convert was produced by a service in kotlin and then converted using this method. When I Copied the contents of the file to another csv file the conversion worked. Could you guide me where the problem is. The rowNumber specified has no data Thank you