`from csv`: Combination of `--flexible` and `--noheaders`
Related problem
Currently, when using from csv with the --flexible and --noheaders flags, the first row determines the amount of columns. I would like some way to instead use the maximum amount of columns, so that no entries are discarded (I am using the --flexible and --noheaders flags in the first place because I do not know the number of columns in advance).
That is, I would like
$ "foo\nbar,baz" | from csv --flexible --noheaders
╭───┬─────────╮
│ # │ column1 │
├───┼─────────┤
│ 0 │ foo │
│ 1 │ bar │
╰───┴─────────╯
to instead return
$ "foo\nbar,baz" | from csv --flexible --noheaders
╭───┬─────────┬─────────╮
│ # │ column1 │ column2 │
├───┼─────────┼─────────┤
│ 0 │ foo │ │
│ 1 │ bar │ baz │
╰───┴─────────┴─────────╯
Describe the solution you'd like
When using from csv in combination with --flexible and --noheaders (or some other additional flag), the returned table should return the full amount of columns, and not a version trimmed based on the number of columns from the first row.
Describe alternatives you've considered
I thought of using lines | each { from csv --noheaders | into record } intead, which works mostly fine, but breaks multiline values.
Compare
$ "\"bar\nbaz\"\nfoo" | from csv --flexible --noheaders
╭───┬─────────╮
│ # │ column1 │
├───┼─────────┤
│ 0 │ bar │
│ │ baz │
│ 1 │ foo │
╰───┴─────────╯
$ "\"bar\nbaz\"\nfoo" | lines | each { from csv --noheaders | into record }
╭───┬─────────╮
│ # │ column1 │
├───┼─────────┤
│ 0 │ bar │
│ 1 │ baz" │
│ 2 │ foo │
╰───┴─────────╯
Additional context and details
No response
Seems like that's the way --flexible --no-headers should work anyway. So, this might be a bug.
I have the same problem, I didn't expect --flexible option to behave this way
Fixed by #14399.