commonMain.com.github.doyaaaaaken.kotlincsv.dsl.CsvReaderDsl.kt Maven / Gradle / Ivy
package com.github.doyaaaaaken.kotlincsv.dsl
import com.github.doyaaaaaken.kotlincsv.client.CsvReader
import com.github.doyaaaaaken.kotlincsv.dsl.context.CsvReaderContext
/**
* DSL Method which provides `CsvReader`
*
* @return CsvReader
*
* Usage example:
*
* 1. Use default setting
*
* val reader: CsvReader = csvReader()
* reader.read("a,b,c\nd,e,f))
*
*
* 2. Customize Setting
*
* val reader: CsvReader = csvReader {
* delimiter = '\t'
* //...
* }
*
*
* @see CsvReaderContext
* @see CsvReader
*
* @author doyaaaaaken
*/
fun csvReader(init: CsvReaderContext.() -> Unit = {}): CsvReader {
val context = CsvReaderContext().apply(init)
return CsvReader(context)
}