HI I have a csv called test.csv . I am trying to read the csv line by line and convert the values into a hash key value pairs . Here is the code :-
test.csv
Using FasterXML's CSV package: https://github.com/FasterXML/jackson-dataformats-text/tree/master/csv
public static List> read(File file) throws JsonProcessingException, IOException { List> response = new LinkedList>(); CsvMapper mapper = new CsvMapper(); CsvSchema schema = CsvSchema.emptySchema().withHeader(); MappingIterator> iterator = mapper.reader(Map.class) .with(schema) .readValues(file); while (iterator.hasNext()) { response.add(iterator.next()); } return response; }