Skip to content

Filter array of subarrays: drop table columns #302

@PsychoTeras

Description

@PsychoTeras

Hi all,

There is a problem I can't solve. I have the following JSON:

{
    "rows": [
        [
            "A1",
            "B1",
            "C1"
        ],
        [
            "A2",
            "B2",
            "C2"
        ],
        [
            "A3",
            "B3",
            "C3"
        ]
    ],
    "columns": [
        "A",
        "B",
        "C"
    ]
}

You can see that it is essentially a table with columns and rows.
So, what I need is to drop some columns and its data. For example, I want to keep column "B" only:

{
    "rows": [
        [
            "B1"
        ],
        [
            "B2"
        ],
        [
            "B3"
        ]
    ],
    "columns": [
        "B"
    ]
}

Ideally, I would like to specify the names of the columns that I want to keep. But it is also ok to hardcode their indexes.

Thanks in advance,
Riz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions