Skip to content

unflatten: An array value unflattens differently depending on whether comma or semi-colon is used #479

@jpmckinney

Description

@jpmckinney

This behavior:

if "," in value:
return [x.split(",") for x in value.split(";")]
else:
return value.split(";")

originates from dcba86e

However, I don't know why ; and , are handled differently.

flatterer uses commas instead of ;. So:

uv run flatten-tool unflatten -s schema.json -f csv dir

where schema.json is:

{
  "properties": {
    "tag": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  }
}

and main.csv in dir/ is:

tag
"a,b,c"

produces:

{
    "main": [
        {
            "tag": [
                [
                    "a",
                    "b",
                    "c"
                ]
            ]
        }
    ]
}

But if you use semi-colons, it's as desired:

{
    "main": [
        {
            "tag": [
                "a",
                "b",
                "c"
            ]
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions