csvstack: handle reordered columns automatically
Created by: metasoarous
I would expect that csvstack would look at headers and stack data intelligently, but it does not. It simply cats the first file together with all but the first line of remaining files.
In particular, if column names occur in a different order, or if some file has columns that another does not, the results are not consistent with what one would expect.
For example:
csvlook a.csv =>
|----+----|
| x | y |
|----+----|
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |
|----+----|
csvlook b.csv =>
|----+-------|
| y | z |
|----+-------|
| 8 | this |
| 9 | that |
|----+-------|
csvstack a.csv b.csv | csvlook =>
|----+-------|
| x | y |
|----+-------|
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |
| 8 | this |
| 9 | that |
|----+-------|
I would expect the following:
csvstack a.csv b.csv | csvlook =>
|----+---+-------|
| x | y | z |
|----+---+-------|
| 1 | 2 | |
| 3 | 4 | |
| 5 | 6 | |
| | 8 | this |
| | 9 | that |
|----|---+-------|