csv

inline fun <T> Flow<T>.csv(appendHeader: Boolean = true, delimiter: String = ";"): Flow<String>

Converts a flow of objects into a flow of CSV strings, using reflection to automatically map object fields to CSV columns.

Return

A flow of CSV strings.

Example usage:

data class Person(val name: String, val age: Int)
val peopleFlow = flowOf(Person("Alice", 30), Person("Bob", 25))

peopleFlow
.csv(appendHeader = true, delimiter = ";")
.collect { line -> println(line) }

Parameters

appendHeader

Whether to append the header row to the CSV output. Defaults to true.

delimiter

The delimiter to use for separating values in the CSV. Defaults to ";".