An open API service indexing awesome lists of open source software.

https://github.com/ykws/kotlin-csv-example

Example use kotlin-csv
https://github.com/ykws/kotlin-csv-example

kotlin-csv

Last synced: 9 months ago
JSON representation

Example use kotlin-csv

Awesome Lists containing this project

README

          

# Example use kotlin-csv

What exception is thrown when try to read a csv file with [kotlin-csv](https://github.com/doyaaaaaken/kotlin-csv)?

## for example

throws **MalformedCSVException** when header 'name' is duplicated.

```kotlin
try {
csvReader().open(assets.open("invalid.csv")) {
// throws MalformedCSVException
readAllWithHeaderAsSequence().forEach { row: Map ->
Log.d("CSV", row.getValue("name"))
}
}
} catch(e: Exception) {
e.printStackTrace()
}
```

throws **NoSuchElementException** when Key ame is missing in the map.

```kotlin
try {
csvReader().open(assets.open("valid.csv")) {
readAllWithHeaderAsSequence().forEach { row: Map ->
// throws NoSuchElementException
Log.d("CSV", row.getValue("ame"))
}
}
} catch(e: Exception) {
e.printStackTrace()
}
```