🌐
DEV Community
dev.to › blackmo18 › kotlin-csv-kotlin-grass-2b8j
Kotlin CSV to Data Class Parser - DEV Community
December 31, 2021 - So I decided to create one, and it is now available on GitHub Kotlin-Grass. Unlike some existing Java CSV parsers, it doesn't require to invade your data class with annotation to map CSV file columns to data class fields.
🌐
Baeldung
baeldung.com › home › kotlin › kotlin io › read and write csv files with kotlin
Read and Write CSV Files With Kotlin | Baeldung on Kotlin
March 19, 2024 - That’s why it’s entirely possible to write a simple parser in pure Kotlin, but using one of the libraries helps us to cover many edge cases. Let’s find a sample CSV file and try to read it: "Year", "Score", "Title" 1968, 86, "Greetings" 1970, 17, "Bloody Mama" 1970, 73, "Hi, Mom!" This file includes all the movies which starred Robert De Niro, their ratings, and the year they were filmed. Let’s assume we want to parse that file into a structure: data class Movie( val year: Year, val score: Int, val title: String, )
Discussions

Use Generics in Kotlin class for parsing CSV - Stack Overflow
I'm getting the below error when I replace my data class with "X" in the line val iterator = getIterator(reader) ... Cannot use 'X' as reified type parameter. Use a class instead. ... Class type parameters cannot be reified, so they cannot be passed to generic methods with reified type parameters. You should store a Class in CSVMigrator... More on stackoverflow.com
🌐 stackoverflow.com
Pulling from a CSV
Do you only ever need to access the data in one direction? The most obvious data structure would be a Map> More on reddit.com
🌐 r/Kotlin
5
1
October 20, 2022
Kotlin reflection - creating objects from CSV - Stack Overflow
So instead of a single object with ... specific data set, I went to one attribute. The best solution, was a key/value pair attribute. I apologize if my Kotlin speak is rusty, I've been focused on python the last two+ years. Dictionary? Essentially, I stripped off the header of my csv, mapped it ... More on stackoverflow.com
🌐 stackoverflow.com
How to export Kotlin's data class list to CSV in android? - Stack Overflow
I am able to find method for exporting Java's list of POJO to csv but unable to find a method to export Kotlin's list of data class to CSV. More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › blackmo18 › kotlin-grass
GitHub - blackmo18/kotlin-grass: Kotlin Csv to Data Class Parser · GitHub
<dependency> <groupId>com.github.doyaaaaaken</groupId> <artifactId>kotlin-csv-jvm</artifactId> <version>0.15.2</version> </dependency> <dependency> <groupId>io.github.blackmo18</groupId> <artifactId>kotlin-grass-core-jvm</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>io.github.blackmo18</groupId> <artifactId>kotlin-grass-parser-jvm</artifactId> <version>0.8.0</version> </dependency> ... data class PrimitiveTypes( val short: Short, val int: Int, val long: Long, val float: Float, val double: Double, val boolean: Boolean, val string: String ) If a variable in your data class is a nullable, all you have to do is mark it with ? data class NullableData( val nullableString: String?, val nullableInt: Int? = null, ... ) val csvContents = csvReader().readAllWithHeader(file) val dataClasses = grass<PrimitiveTypes>().harvest(csvContents)
Starred by 37 users
Forked by 8 users
Languages   Kotlin
🌐
Kotlin
kotlinlang.org › docs › data-analysis-work-with-data-sources.html
Retrieve data from files | Kotlin Documentation
3 weeks ago - Kotlin DataFrame library enables you to work with both non-structured and structured data. For data transformations, you can use such methods as .add(), .split(), .convert(), and .parse(). Additionally, this toolset enables the retrieval and manipulation of data from various structured file formats, including CSV, JSON, XLS, Parquet, and Apache Arrow.
🌐
Floern
floern.com
CSV in Kotlin with Casting CSV – floern.com;;
The Kotlin compiler generates a property and its backing field for each constructor parameter, but annotations added to parameters are not propagated to the properties and fields. So if we use reflection to get the annotations of a field, we won't get any... We can fix that by listing the annotation with the use-site targets field and property in addition to param: data class MyClass( @param:CsvTypeAdapter(DateAdapter::class) @field:CsvTypeAdapter(DateAdapter::class) @property:CsvTypeAdapter(DateAdapter::class) val date: Date )
🌐
Medium
medium.com › att-israel › jackson-csv-reader-writer-using-kotlin-f37ae771bd6d
Jackson CSV Reader/Writer Using Kotlin | by Ittay Stern | AT&T Israel Tech Blog | Medium
September 16, 2020 - Jackson CSV Reader/Writer Using Kotlin So you’re writing in Kotlin and you want to load your CSV files to a List, or maybe dump your Collection to a CSV file. This is 100% reasonable, given that
🌐
The Syntax Diaries
thesyntaxdiaries.com › tools › csv-to-kotlin
CSV to Kotlin Data Class Generator | Convert CSV to Kotlin Instantly
Free online tool to convert CSV files into Kotlin data classes. Instantly generate Kotlin models from your CSV data for seamless integration.
Find elsewhere
🌐
Stack Abuse
stackabuse.com › reading-and-writing-csv-files-in-kotlin-with-apache-commons
Reading and Writing CSV Files in Kotlin with Apache Commons
February 27, 2023 - Finally, with the library added to our project, let's define the CSV file we're going to read - students.csv: 101,John,Smith,90 203,Mary,Jane,88 309,John,Wayne,96 · It'll be located under /resources/students.csv. Also, since we'll be reading these records into custom objects, let's make a data class:
🌐
Nick-tomlin
nick-tomlin.com › posts › using-jackson-csv-with-kotlin
Using Jackson CSV with kotlin - Nick Tomlin
April 15, 2020 - This was obvious when I found the solution and tracked it back to the documentation, but not so obvious when I first encountered it. ... import com.fasterxml.jackson.dataformat.csv.CsvMapper import com.fasterxml.jackson.dataformat.csv.CsvSchema import com.fasterxml.jackson.module.kotlin.KotlinModule data class Customer(val id: Int) fun main () { val mapper = CsvMapper() val csv = "id\n1234" val customers = mapper.readerFor(Customer::class.java) .with(CsvSchema.emptySchema().withHeader()) .readValues<Customer>(csv) .readAll() println(customers) }
🌐
SSOJet
ssojet.com › serialize-and-deserialize › serialize-and-deserialize-csv-in-kotlin
Serialize and Deserialize CSV in Kotlin | Serialize and Deserialize Data in Programming Languages
December 13, 2025 - Instead of manually splitting strings and managing column indices, libraries like kotlinx-serialization-csv allow you to map CSV rows directly to Kotlin data classes.
🌐
Kotlinlang
slack-chats.kotlinlang.org › t › 469065 › would-it-be-difficult-to-write-a-csv-parser-that-maps-lines-
Would it be difficult to write a CSV parser that maps lines kotlinlang #android
October 12, 2021 - Ah ok you mean to use the CSV and create an intermediate format like JSON from this CSV. ok I guess I can't follow. The JSON file should describe the model? ... @Casey Brooks for mapping to a data class, Kotlin reflection should be fine, and that does have access to nullity etc.
🌐
Gitbook
kenta-koyama-biz.gitbook.io › kotlin-csv
README | kotlin-csv
January 20, 2024 - kotlin-grass: Csv File to Kotlin Data Class Parser. Contributions, issues and feature requests are welcome! If you have questions, ask away in Kotlin Slack's kotlin-csv room. Give a ⭐️ if this project helped you! Copyright © 2024 jsoizo. This project is licensed under Apache 2.0.
🌐
GitHub
github.com › Floern › casting-csv-kt
GitHub - Floern/casting-csv-kt: Read and write CSV directly from and to Kotlin data classes.
A simple Kotlin library to read and write CSV directly from and to data classes with a single line of code.
Starred by 11 users
Forked by 2 users
Languages   Kotlin 100.0% | Kotlin 100.0%
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
CSV to Kotlin Data Class - Visual Studio Marketplace
September 1, 2021 - Extension for Visual Studio Code - Given a CSV file, generate a reasonable kotlin data class
🌐
ZetCode
zetcode.com › kotlin › csv
Kotlin CSV - read, write CSV files in Kotlin
January 29, 2024 - The example reads numbers from the numbers.csv file and prints them to the console. ... The file is located in the src/main/resources directory. ... The CSVReader is a class used for reading CSV files.