Notgnoshi / dotfiles

Personal dotfiles and shell scripts
https://agill.xyz
0 stars 0 forks source link

csvplot: Interleave multiple CSV files with a common column #125

Open Notgnoshi opened 6 months ago

Notgnoshi commented 6 months ago

File A:

x,y
0,0
1,1
2,2

File B:

x,y,z
0.5,0.5,1
1.5,1.5,2
2.5,2.5,3

Interleaved:

x,y,z
0,0,
0.5,0.5,1
1,1,
1.5,1.5,2
2,2,
2.5,2.5,3
Notgnoshi commented 4 months ago

qsv can do this

$ qsv joinp --coalesce --full x,y 1.csv x,y 2.csv
x,y,z
0.5,0.5,1
1.5,-6.0,2
2.5,3.0,3
1.0,1.0,
0.0,0.0,
2.0,2.0,
(6, 3)

Note the extra shape (6, 3) line printed to stderr at the end. Useful for sanity checking

$ qsv joinp --coalesce --full x,y 1.csv x,y 2.csv | qsv sort -s x -N
x,y,z
0.0,0.0,
0.5,0.5,1
1.0,1.0,
1.5,-6.0,2
2.0,2.0,
2.5,3.0,3