Skip to content

Unifying Read & Write Interface #1

@asarrabay

Description

@asarrabay

Currently we have asymmetric interface between read and write tabular data :
Read :

File(pathTo("simple_data.xlsx")).inputStream().use {
        val columns = object:RetableColumns() {
            val FIRST_NAME = string("first_name", index = 2)
            val LAST_NAME  = string("last_name", index = 1)
            val AGE        = int("age", index = 3)
        }
        val retable = Retable
                            .csv(columns)
                            .read(it)
}

Write :

        val columns = object:RetableColumns() {
            val FIRST_NAME = string("first_name", index = 2)
            val LAST_NAME  = string("last_name", index = 1)
            val AGE        = int("age", index = 3)
        }
        Retable(columns)
            .data(
                    listOf(
                            Person("John", "Doe", 23),
                            Person("Jenny", "Boe", 25)
                    )
            ) {
                    mapOf(
                            FIRST_NAME to it.firstName,
                            LAST_NAME to it.lastName,
                            AGE to it.age
                    )
            }
            .write(Retable.excel(columns) to File(pathTo("export_data_cols.xlsx")).outputStream())

It's would better to have same code to read and write a file until we call read or write method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions