我只是厌倦了使用该join
命令而没有得到想要的结果,并且它返回了一些错误。
还有一件事我已经阅读了与join
命令相关的所有查询here和SuperUser,但未能成功。
我该如何使用join
或awk
?
file1.csv
autoid|Mycolumn
5|Odhav, Gujarat, 380010
7|Navrangpura, Gujarat, 380009
16|Kalupur, Gujarat, 380002
32|Naroda, Gujarat, 380025
62|Khamasa, Gujarat, 380001
73|Sola Road, Gujarat, 380063
74|Railwaypura, Gujarat, 380002
78|Meghaninagar, Gujarat, 380016
85|Thaltej, Gujarat, 380054
file2.csv
5|Odhav, Gujarat, 380010|22.406347|73.824345
7|Navrangpura, Gujarat, 380009|22.328403|73.881841
16|Kalupur, Gujarat, 380002|22.379901|73.814217
32|Naroda, Gujarat, 380025|22.417059|73.887806
38|Raikhad, Gujarat, 380001|22.491544|73.782878
39|Ashram Road, Gujarat, 380006|22.279248|73.846393
44|Raipur, Gujarat, 380002|22.346186|73.87462
56|Jamalpur, Gujarat, 380022|22.518504|73.785024
58|Patharkuva, Gujarat, 380001|22.308473|73.825071
62|Khamasa, Gujarat, 380001|22.100711|73.707207
73|Sola Road, Gujarat, 380063|22.026236|73.732926
74|Railwaypura, Gujarat, 380002|21.992994|73.86893
78|Meghaninagar, Gujarat, 380016|21.955106|73.878629
85|Thaltej, Gujarat, 380054|21.989253|73.735725
我正在使用此命令,但无法获得所需的结果:
$ join -t'|' -1 2 -2 2 <(sort -k2 Areaprob.csv) <(sort -k2 Com_remoteArea.csv)>output.csv
它返回这样的东西;如您所见,我已经在使用上面给出的sort
命令join
。
join: file 1 is not in sorted order
join: file 2 is not in sorted order
我output.csv
看起来像这样 - 它不会返回所有 9 条记录file1.csv
Mycolumn|autoid|autoid|Gis_lat|Gis_long
Khamasa, Gujarat, 380001|62|62|22.100711|73.707207
Railwaypura, Gujarat, 380002|74|74|21.992994|73.86893
Thaltej, Gujarat, 380054|85|85|21.989253|73.735725
Sola Road, Gujarat, 380063|73|73|22.026236|73.732926