Compare columns in 2 files and put information according to file 1 [duplicate]
This question already has an answer here:
intersection of two files according to the first column
1 answer
I have 2 files, file 1 and file 2 and I want to compare column 1 in file to column 1 in file 2 and have additional column generated with column 2 in file 3
File 1:
9001 Whitby On
9002 Toronto On
9003 Scarborough On
9004 Victoria BC
9005 Vancouver BC
File 2:
9001 501
9002 502
9003 503
9004 504
9005 505
Output:
501 9001 Whitby On
502 9002 Toronto On
503 9003 Scarborough On
504 9004 Victoria BC
505 9005 Vancouver BC
text-processing join
marked as duplicate by don_crissti, Mr Shunz, Jeff Schaller, Shadur, Christopher Jan 10 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
intersection of two files according to the first column
1 answer
I have 2 files, file 1 and file 2 and I want to compare column 1 in file to column 1 in file 2 and have additional column generated with column 2 in file 3
File 1:
9001 Whitby On
9002 Toronto On
9003 Scarborough On
9004 Victoria BC
9005 Vancouver BC
File 2:
9001 501
9002 502
9003 503
9004 504
9005 505
Output:
501 9001 Whitby On
502 9002 Toronto On
503 9003 Scarborough On
504 9004 Victoria BC
505 9005 Vancouver BC
text-processing join
marked as duplicate by don_crissti, Mr Shunz, Jeff Schaller, Shadur, Christopher Jan 10 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
intersection of two files according to the first column
1 answer
I have 2 files, file 1 and file 2 and I want to compare column 1 in file to column 1 in file 2 and have additional column generated with column 2 in file 3
File 1:
9001 Whitby On
9002 Toronto On
9003 Scarborough On
9004 Victoria BC
9005 Vancouver BC
File 2:
9001 501
9002 502
9003 503
9004 504
9005 505
Output:
501 9001 Whitby On
502 9002 Toronto On
503 9003 Scarborough On
504 9004 Victoria BC
505 9005 Vancouver BC
text-processing join
This question already has an answer here:
intersection of two files according to the first column
1 answer
I have 2 files, file 1 and file 2 and I want to compare column 1 in file to column 1 in file 2 and have additional column generated with column 2 in file 3
File 1:
9001 Whitby On
9002 Toronto On
9003 Scarborough On
9004 Victoria BC
9005 Vancouver BC
File 2:
9001 501
9002 502
9003 503
9004 504
9005 505
Output:
501 9001 Whitby On
502 9002 Toronto On
503 9003 Scarborough On
504 9004 Victoria BC
505 9005 Vancouver BC
This question already has an answer here:
intersection of two files according to the first column
1 answer
text-processing join
text-processing join
edited Jan 10 at 19:00
Rui F Ribeiro
39.5k1479133
39.5k1479133
asked Jan 9 at 21:00
Muhammad Umair KhanMuhammad Umair Khan
11
11
marked as duplicate by don_crissti, Mr Shunz, Jeff Schaller, Shadur, Christopher Jan 10 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by don_crissti, Mr Shunz, Jeff Schaller, Shadur, Christopher Jan 10 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
you could use Miller http://johnkerl.org/miller/doc/
If your files are two TSV the command is
mlr --tsv --implicit-csv-header --headerless-csv-output join --ul -l 1 -r 1 -j 1 --lp l --rp r -f file1.csv file2.csv
And you have
9001 Whitby On 501
9002 Toronto On 502
9003 Scarborough On 503
9004 Victoria BC 504
9005 Vancouver BC 505
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you could use Miller http://johnkerl.org/miller/doc/
If your files are two TSV the command is
mlr --tsv --implicit-csv-header --headerless-csv-output join --ul -l 1 -r 1 -j 1 --lp l --rp r -f file1.csv file2.csv
And you have
9001 Whitby On 501
9002 Toronto On 502
9003 Scarborough On 503
9004 Victoria BC 504
9005 Vancouver BC 505
add a comment |
you could use Miller http://johnkerl.org/miller/doc/
If your files are two TSV the command is
mlr --tsv --implicit-csv-header --headerless-csv-output join --ul -l 1 -r 1 -j 1 --lp l --rp r -f file1.csv file2.csv
And you have
9001 Whitby On 501
9002 Toronto On 502
9003 Scarborough On 503
9004 Victoria BC 504
9005 Vancouver BC 505
add a comment |
you could use Miller http://johnkerl.org/miller/doc/
If your files are two TSV the command is
mlr --tsv --implicit-csv-header --headerless-csv-output join --ul -l 1 -r 1 -j 1 --lp l --rp r -f file1.csv file2.csv
And you have
9001 Whitby On 501
9002 Toronto On 502
9003 Scarborough On 503
9004 Victoria BC 504
9005 Vancouver BC 505
you could use Miller http://johnkerl.org/miller/doc/
If your files are two TSV the command is
mlr --tsv --implicit-csv-header --headerless-csv-output join --ul -l 1 -r 1 -j 1 --lp l --rp r -f file1.csv file2.csv
And you have
9001 Whitby On 501
9002 Toronto On 502
9003 Scarborough On 503
9004 Victoria BC 504
9005 Vancouver BC 505
edited Jan 10 at 8:38
answered Jan 10 at 7:58
aborrusoaborruso
20619
20619
add a comment |
add a comment |