CSV parser in JAVA, double quotes in string (SuperCSV, OpenCSV)

后端 未结 3 1687
情话喂你
情话喂你 2021-01-15 14:31

all day I\'ve been searching how to resolve this probem and nothing... I want to write function, which convert CSV file to collection of lists (of strings). Here is this fun

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-15 15:08

    You create your own Preference.

    CsvPreference excelPreference = new CsvPreference.Builder('\'', ',', "\n").build();
    CsvListReader parser = new CsvListReader(Files.newBufferedReader(pathToFile , StandardCharsets.UTF_8), excelPreference);
    

    After that, it will output as expected. In this example, you will strip the single quote if you have that in your csv file and keep the double quote untouched.

提交回复
热议问题