Skip to content

Include metadata in the parse result for renamed columns #988

@jchen042

Description

@jchen042

Great project!
@pokoli - thanks for the update w.r.t. #982 #129 #956 . Will the lib consider adding the configs for the duplicated header? i.e. enable/disable the automatic renaming while keeping the capacity of reading the right column value, or including the renaming metadata to the ParseResult so the end developer will have more options to handle this scenario?

My proposal will be including the metadata to each column:

With the following CSV data:

c;c;c;c_1
1;2;3;4

The ParseResult.data will be like:

[{
  "c": {
    "originalName": "c",
    "value": "1"
  },
  "c_1": {
    "originalName": "c"
    "value": "2"
  },
  "c_2": {
    "originalName": "c",
    "value": 3
  },
  "c_3": {
    "originalName": "c",
    "value": 4
  }
}]

Alternatively, the column renaming metadata can be included in ParseResutl.meta, like:

"columnNameMapping": {
  "c": "c",
  "c_1": "c",
  "c_2": "c",
  "c_3": "c",
}

If this is a good idea, I'm happy to create a PR to handle it.

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