
Small, fast CSV parser and builder, enabling CSV creation, text conversion, and parsing with minimalistic, self-explanatory API. Supports CSV transformation and column-based data manipulation.
A tiny, fast Kotlin Multiplatform library for parsing and building CSV strings. Zero dependencies, explicit API, and predictable behavior.
Platforms: JVM, JS (Browser/Node), iOS, macOS, Linux, Windows
Contributions welcome — please keep the API minimalistic and self-explanatory.
val csv = buildCsv {
header {
column("Code")
column("Name")
}
data {
value("DE")
value("Deutschland")
}
data {
value("BY")
value("Belarus")
}
} as CsvWithHeaderval code = csv.header.columnByName("Code")!! // CsvColumn(index=0, name="Code")
val name = csv.header.columnByName("Name")!! // CsvColumn(index=1, name="Name")
csv.data[0][code] // "DE"
csv.data[0][name] // "Deutschland"
csv.data[1][code] // "BY"
csv.data[1][name] // "Belarus"val text = csv.toCsvText()
// "Code,Name\nDE,Deutschland\nBY,Belarus\n"
// With CRLF line endings:
csv.toCsvText(newLine = NewLine.CRLF)// With header row:
val csv = CsvWithHeader.fromCsvText("Code,Name\nDE,Deutschland\n")
// Without header row:
val csv = CsvNoHeader.fromCsvText("DE,Deutschland\nBY,Belarus\n")val transformed = csv.copy(
data = csv.data.map { row ->
row.mapValueOf(name) { value ->
if (value == "Belarus") "Weißrussland" else value
}
}
)In gradle/libs.versions.toml
[versions]
kotlin = "2.3.0"
csv = "1.3"
[libraries]
csv = { module = "de.halfbit:csv", version.ref = "csv" }
[plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }In shared/build.gradle.kts
plugins {
alias(libs.plugins.kotlin.multiplatform)
}
kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.csv)
}
}
}build.gradle.kts of the root project./gradlew clean build releaseToMavenCentralCopyright 2023-2026 Sergej Shafarenka, www.halfbit.de
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
A tiny, fast Kotlin Multiplatform library for parsing and building CSV strings. Zero dependencies, explicit API, and predictable behavior.
Platforms: JVM, JS (Browser/Node), iOS, macOS, Linux, Windows
Contributions welcome — please keep the API minimalistic and self-explanatory.
val csv = buildCsv {
header {
column("Code")
column("Name")
}
data {
value("DE")
value("Deutschland")
}
data {
value("BY")
value("Belarus")
}
} as CsvWithHeaderval code = csv.header.columnByName("Code")!! // CsvColumn(index=0, name="Code")
val name = csv.header.columnByName("Name")!! // CsvColumn(index=1, name="Name")
csv.data[0][code] // "DE"
csv.data[0][name] // "Deutschland"
csv.data[1][code] // "BY"
csv.data[1][name] // "Belarus"val text = csv.toCsvText()
// "Code,Name\nDE,Deutschland\nBY,Belarus\n"
// With CRLF line endings:
csv.toCsvText(newLine = NewLine.CRLF)// With header row:
val csv = CsvWithHeader.fromCsvText("Code,Name\nDE,Deutschland\n")
// Without header row:
val csv = CsvNoHeader.fromCsvText("DE,Deutschland\nBY,Belarus\n")val transformed = csv.copy(
data = csv.data.map { row ->
row.mapValueOf(name) { value ->
if (value == "Belarus") "Weißrussland" else value
}
}
)In gradle/libs.versions.toml
[versions]
kotlin = "2.3.0"
csv = "1.3"
[libraries]
csv = { module = "de.halfbit:csv", version.ref = "csv" }
[plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }In shared/build.gradle.kts
plugins {
alias(libs.plugins.kotlin.multiplatform)
}
kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.csv)
}
}
}build.gradle.kts of the root project./gradlew clean build releaseToMavenCentralCopyright 2023-2026 Sergej Shafarenka, www.halfbit.de
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.