I have a large .csv file (about 300 MB) that is read from a remote host and parsed to the target file, but I do not need to copy all the lines to the target file. During copying, I need to read each line from the source, and if it passes some predicate, add the line to the target file.
I believe Apache CSV ( apache.commons.csv ) can parse the whole file
CSVFormat csvFileFormat = CSVFormat.EXCEL.withHeader(); CSVParser csvFileParser = new CSVParser("filePath", csvFileFormat); List<CSVRecord> csvRecords = csvFileParser.getRecords();
therefore, I cannot use BufferedReader . Based on my code, an instance of new CSVParser() should be created for each line that looks inefficient.
How can I parse a single row (with a known table header) in the above case?
java large-files csv filtering apache-commons-csv
Alex orlov
source share