Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Latest commit

 

History

History
95 lines (68 loc) · 2.65 KB

readme.md

File metadata and controls

95 lines (68 loc) · 2.65 KB

Kotools CSV

Maven Central Kotlin

Kotools CSV is a lightweight library for managing CSV files with elegant Kotlin DSLs.

data class Person(val name: String, val age: Int, val isAdmin: Boolean = false)

suspend fun main() {
    csvWriter<Person> {
        file = "people"
        records { +Person("Nobody", 25) }
    }
    val people: List<Person> = csvReader { file = "people" }
    println(people)
}

Design goals

Lightweight

Kotools CSV just ship with what you need for manipulating CSV files, and has only 3 direct dependencies:

Explicit error handling

Kotools CSV lets you choose explicitly how to handle errors following the design of Kotlin Standard Library: if something goes wrong, functions suffixed by OrNull will return null and other functions will throw an IllegalStateException. With this explicit design, you can orchestrate easily your application state in production.

Simply elegant

This library provides intuitive type-safe builders (also known as DSLs) for readability and maintainability purpose. So you can focus on what's important in your code, instead of trying to guess what is the good way to retrieve a file from resources or a file only present at runtime. Simplicity is key.

Installation

Gradle

Kotlin DSL

implementation("io.github.kotools:csv:2.2.0")

Groovy DSL

implementation 'io.github.kotools:csv:2.2.0'

Maven

<dependency>
    <groupId>io.github.kotools</groupId>
    <artifactId>csv</artifactId>
    <version>2.2.0</version>
</dependency>

Documentation

Latest documentation of Kotools CSV is available here. Also, you can find more information about CSV format in the RFC 4180.

Contributing

Feel free to contribute to the project with issues and pull requests.

License

This project is licensed under the MIT License.