简体   繁体   English

使用 awk 将多个文件 csv 合并为一个文件

[英]Combine multiple files csv into one using awk

I want to combine two.csv files based on the unique id that exists in both files.我想根据两个文件中存在的唯一 ID 合并两个 .csv 文件。 First file consist of 17 columns and the second one in 2 columns where in both files the first column is the same unique id.第一个文件由 17 列组成,第二个文件由 2 列组成,在两个文件中,第一列是相同的唯一 ID。 In the to be created file 3 i would like 18 columns.在要创建的文件 3 中,我想要 18 列。 I have been trying paste我一直在尝试粘贴

paste -d ' ' SPOOL1.csv SPOOL2.csv > MERGED.csv粘贴-d ' ' SPOOL1.csv SPOOL2.csv > MERGED.csv

but that of course does not take the unique columns into consideration.但这当然没有考虑到独特的列。 Not proficient in awk so all help is appreciated.不精通 awk,因此不胜感激。 Thanks谢谢

sounds like if the files are sorted then听起来如果文件被排序然后
join SPOOL1 SPOOL2 > MERGED
should get you closer if you deal with the delimiters not shown如果你处理未显示的分隔符,应该会让你更接近

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM