Reputation: 1595
I need to write in a specific cell in a .csv
file with org.apache.commons.csv
library whitout iterate and copy all lines.
I tried this:
Reader reader = Files.newBufferedReader(Paths.get(Properties.dataFilePath));
CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT);
List<CSVRecord> records = csvParser.getRecords();
records.get(rowNumber)[columnIndex] = value;
However it is not allowed.
Edit 1
My IDE mentioned : The type of the expression must be an array type but it resolved to CSVRecord
Upvotes: 1
Views: 1300
Reputation: 104
have you tried it with
value = records.get(rowNumber).get(columnIndex);
?
Have a look here, it may help you: https://commons.apache.org/proper/commons-csv/apidocs/org/apache/commons/csv/CSVRecord.html
Upvotes: 1