Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unifying Read & Write Interface #1

Open
asarrabay opened this issue Oct 21, 2020 · 0 comments
Open

Unifying Read & Write Interface #1

asarrabay opened this issue Oct 21, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@asarrabay
Copy link
Collaborator

asarrabay commented Oct 21, 2020

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.

@asarrabay asarrabay added the enhancement New feature or request label Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant