0

I have one file that has list of Ids like

File1.csv

123456
1234234
2324324
325435345

and other file structure is like this:

File2.csv

  1234234,asadasdas!w2eaesfd+smakdnjads,"points-ka"
  2131231,sadfasfa990-0;;'.sadsadsada,"points-ka"
  2324324,asadasdas!w2eaesfd+smasdasdfadewe,"points-ka"
  5434234234,adasdfsfhguse38873h78hu8i8377&*&*,"points-ka"

Now, I want to join the files using this command

join -t, file1.csv file2.csv

but this is not returning any output where am I going wrong?

Required Output:

 1234234,asadasdas!w2eaesfd+smakdnjads,"points-ka"
 2324324,asadasdas!w2eaesfd+smasdasdfadewe,"points-ka"
Aki008
  • 405
  • 2
  • 6
  • 19

2 Answers2

1

The files have to be sorted on the join key before join will work.

sort file1.csv > file1sorted.csv
sort file2.csv > file2sorted.csv
join -t, f1s.csv f2s.csv

1234234,asadasdas!w2eaesfd+smakdnjads,"points-ka"
2324324,asadasdas!w2eaesfd+smasdasdfadewe,"points-ka"
harmic
  • 28,606
  • 5
  • 67
  • 91
0

A requisite of join is that the files should be sorted first.

$ sort File1.csv > File1.sorted.csv

$ sort File2.csv > File2.sorted.csv

$ join -t, File1.sorted.csv File2.sorted.csv
1234234,asadasdas!w2eaesfd+smakdnjads,"points-ka"
2324324,asadasdas!w2eaesfd+smasdasdfadewe,"points-ka"
Kokkie
  • 546
  • 6
  • 15
  • sort won't work here because one file is of 25 GB - so, running out of memory ... can you provide any other alternatives? – Aki008 Jul 16 '14 at 12:20
  • Does this help you in any way? http://stackoverflow.com/questions/4544709/compare-two-files-line-by-line-and-generate-the-difference-in-another-file – Kokkie Jul 16 '14 at 12:22