Unix连接无法正常工作

时间:2017-01-07 05:38:26

标签: csv unix join left-join

file1.csv

Id|S1|S2|S3|S4|S5
11024|Female|Female|19390212|0|
11025|Male|Male|19430914|0|
11026|Male|Male|19330714|0|
11027|Female|Female|19211217|0|
11028|Female|Female|19391117|0|
11029|Female|Female|19420207|0|
11030|Female|Female|19700427|0|
11031|Female|Female|19340704|0|
11032|Female|Female|19370818|0|

file2.csv

Id|COl1|COl2|Col3|Col4|Col5|Col6|Col7|Col8|Col9
11028|20150930|160.02|0.00|0.00|||||
11030|20151026|160.02|0.00|0.00|||||
11254|20160328|0.00|0.00|0.00|||||
11254|20160502|0.00|78.64|0.00|||||
11258|20150908|157.48|0.00|0.00|||||
11276|20151023|0.00|0.00|0.00|||||
11278|20150424|170.18|||||||
11278|20150710|0.00|0.00|0.00|||118.00|70.00|
11278|20150821|0.00|0.00|0.00|||122.00|72.00|

结果:

Id|S1|S2|S3|S4|S5
|Col1|Col2|Col3|Col4|Col5|Col6|Col7|Col8
11024|Female|Female|19390212|0|
||||||||
11025|Male|Male|19430914|0|
||||||||
11026|Male|Male|19330714|0|
||||||||
11027|Female|Female|19211217|0|
||||||||
11028|Female|Female|19391117|0|
|20150930|160.02|0.00|0.00||||
11029|Female|Female|19420207|0|
||||||||
11030|Female|Female|19700427|0|
|20151026|160.02|0.00|0.00||||
11031|Female|Female|19340704|0|
||||||||
11032|Female|Female|19370818|0|||||||||

正如您所见,标题和行已加入但在另一行中。为什么? 预期输出:来自两个文件的行在同一行中连接。

使用的命令:

join --header -t '|' -1 1 -2 1 -o 1.1,1.2,1.3,1.4,1.5,1.6,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9 file1.csv file22.csv -a1 > Result.csv

0 个答案:

没有答案