Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff <(cut -d, -f2 file1) <(cut -d, -f3 file2)
- def identical_files?(file1, field1, file2, field2)
- %x{diff <(cut -d, -f#{field1} #{file1}) <(cut -d, -f#{field2} #{file2})}.blank?
- end
- `bash -c 'cat <(echo foo)'` #=> "foo"
- require 'csv'
- csv_file1 = CSV.open('file1')
- csv_file2 = CSV.open('file2')
- until (csv_file1.eof? || csv_file2.eof?) do
- row1 = csv_file1.shift
- row2 = csv_file2.shift
- # do something to diff the fields
- puts "#{ csv_file1.lineno }: #{ row1[1] } == #{ row2[2] } --> #{ row1[1] == row2[2] }"
- end
- [
- [csv_file1, 'file1'],
- [csv_file2, 'file2']
- ].each do |f, fn|
- puts "Hit EOF for #{ fn }" if f.eof?
- f.close
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement