I have the following code to read from CSV file in java. It works fine except for the case when I have commas in my column values. I got the exception.
code:
FileReader fileReader = new FileReader(file); CSVReader csvReader = new CSVReader(fileReader); String[] headers = csvReader.readNext(); List<String[]> rows = csvReader.readAll(); Exception:
Exception in thread "main" com.opencsv.exceptions.CsvMalformedLineException: Unterminated quoted field at end of CSV line. Beginning of lost text
CSVReaderclass should be able to handle this. It is probable that your CSV input is not correct and has formatting errors, which causes the error message.