What exception is thrown when try to read a csv file with kotlin-csv?
throws MalformedCSVException when header 'name' is duplicated.
try {
csvReader().open(assets.open("invalid.csv")) {
// throws MalformedCSVException
readAllWithHeaderAsSequence().forEach { row: Map<String, String> ->
Log.d("CSV", row.getValue("name"))
}
}
} catch(e: Exception) {
e.printStackTrace()
}
throws NoSuchElementException when Key ame is missing in the map.
try {
csvReader().open(assets.open("valid.csv")) {
readAllWithHeaderAsSequence().forEach { row: Map<String, String> ->
// throws NoSuchElementException
Log.d("CSV", row.getValue("ame"))
}
}
} catch(e: Exception) {
e.printStackTrace()
}