我一直在尝试将两个csv文件与基于它们共享的列名的字母数字数据相结合,以便使用terminal对它们执行类似的连接。
以下是我尝试的:(我的两个文件的第一列是相同的)
联接-t,-1 1-2 1 file\u 1。csv文件\u 2。csv>文件\u 3。csv
合并进行得很好,我的列被合并了,但不是我想要的格式。
问题:
file\u 3由两个文件的行组成,虽然用逗号分隔,但在单独的行中。
示例:
Columns from file_1
,Columns from file_2
Row1 from file_1
,Row1 from file_2
Row2 from file_1
,Row2 from file_2
如何在每行合并的一行中获取file\u 3数据?如有任何继续进行的指示,将不胜感激。
文件\u 1。csv:(示例数据)
Id,Age,Employment,Education,Marital,Occupation,Income,Gender,Deductions,Hours,Adjusted
1,38,Private,College,Unmarried,Service,81838,Female,0,72,0
2,35,Private,Associate,Absent,Transport,72099,Male,0,30,0
3,32,Private,HSgrad,Divorced,Clerical,154676.74,Male,0,40,0
文件2。csv:(示例数据)
Id,Adjusted,Predicted_Adjusted,Probability_0,Probability_1
1,0,0,0.952957896225136,0.0470421037748636 .
2,0,0,0.973664421132328,0.0263355788676716 .
3,0,0,0.966224074718457,0.0337759252815426
错误连接:
Id,Age,Employment,Education,Marital,Occupation,Income,Gender,Deductions,Hours,Adjusted
,Adjusted,Predicted_Adjusted,Probability_0,Probability_1
1,38,Private,College,Unmarried,Service,81838,Female,0,72,0
,0,0,0.952957896225136,0.0470421037748636
2,35,Private,Associate,Absent,Transport,72099,Male,0,30,0
,0,0,0.973664421132328,0.0263355788676716
3,32,Private,HSgrad,Divorced,Clerical,154676.74,Male,0,40,0
,0,0,0.966224074718457,0.0337759252815426
预期输出:
每两行实际上是一行,因此预期的输出不应将行拆分为两行,而应表示两个csv文件(即file\u 1和file\u 2)的同质合并