Perl - 按通用维度连接文件中指标的脚本
我想根据共同维度将 3 个文件中的指标连接到 1 个文件中。
例如:
File 1: A B C 10 20 A D C 30 40
File 2: A B C 100 200 A D C 300 400
File 3: A B C 1000 A D C 3000
Output File: A B C 10 20 100 200 1000 A D C 30 40 300 400 3000
I want to concatenate the metrics from 3 files into 1 files based on common dimensions.
Eg:
File 1: A B C 10 20 A D C 30 40
File 2: A B C 100 200 A D C 300 400
File 3: A B C 1000 A D C 3000
Output File: A B C 10 20 100 200 1000 A D C 30 40 300 400 3000
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将创建一个散列,其中每个键都是文件输入中的前 3 个字段,并迭代每个文件,将值推送到一个数组中,该数组就是散列的值。
请告诉我您是否想查看实际代码。
I would create a hash, where every key is first 3 fields from the file input, and iterate through every file pushing the values into an array which is the value of the hash.
Please let me know whether you would like to see actual code.
你真的不需要 perl 来做到这一点。这是一个有效的 2 行 shell 脚本:
file5 有你的输出数据
You really don't need perl for this. Here's a 2 line shell script that works:
file5 has your output data