parseCsv
Parses the CSV data from a flow of strings and emits each row as a list of strings.
Return
A flow of lists of strings, each representing a row of parsed CSV values.
Example usage:
val csvFlow = flowOf("Name;Age", "Alice;30", "Bob;25")
csvFlow.parseCsv().collect { row -> println(row) }
Content copied to clipboard
Parameters
delimiter
The delimiter to use for separating values in the CSV. Defaults to ";".
Parses the CSV data from a flow of strings and emits each row as a custom object, converted using the provided function.
Return
A flow of custom objects, each representing a row of parsed CSV values.
Example usage:
data class Person(val name: String, val age: Int)
val csvFlow = flowOf("Name;Age", "Alice;30", "Bob;25")
csvFlow
.parseCsv { (name, age) -> Person(name, age.toInt()) }
.collect { person -> println(person) }
Content copied to clipboard
Parameters
delimiter
The delimiter to use for separating values in the CSV. Defaults to ";".
f
The function to convert the parsed row (list of strings) into a custom object.