How can I process a large file via CSVParser?

前端 未结 2 1737
借酒劲吻你
借酒劲吻你 2021-01-04 20:22

I have a large .csv file (about 300 MB), which is read from a remote host, and parsed into a target file, but I don\'t need to copy all the lines to the target

2条回答
  •  一整个雨季
    2021-01-04 21:01

    This is a late response, but you CAN use a BufferedReader with the CSVParser:

    try (BufferedReader reader = new BufferedReader(new FileReader(fileName), 1048576 * 10)) {
        Iterable records = CSVFormat.RFC4180.parse(reader);
        for (CSVRecord line: records) {
            // Process each line here
        }
    catch (...) { // handle exceptions from your bufferedreader here
    

提交回复
热议问题