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
- Host: GitHub
- URL: https://github.com/ykws/kotlin-csv-example
- Owner: ykws
- Created: 2022-01-29T03:47:29.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-29T03:59:27.000Z (almost 4 years ago)
- Last Synced: 2025-01-28T13:50:24.462Z (11 months ago)
- Topics: kotlin-csv
- Language: Kotlin
- Homepage: https://github.com/doyaaaaaken/kotlin-csv
- Size: 95.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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()
}
```