Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. require 'csv'
  2. require 'json'
  3.  
  4. csv_file = ARGV[0]
  5. json_file = File.read(ARGV[1])
  6. json_hash = JSON.parse(json_file)
  7. product = 0
  8. how_many_times = 0
  9.  
  10. json_hash.each do |k, v|
  11.  
  12. is_in_CSV = 0
  13.  
  14. CSV.foreach(csv_file) do |row|
  15.  
  16. if k == row[1] then
  17. is_in_CSV += 1
  18. end
  19.  
  20. end
  21.  
  22. if is_in_CSV == 0 then
  23.  
  24. how_many_times += 1
  25.  
  26. if(how_many_times == 1) then
  27. product = 1
  28. end
  29.  
  30. product *= v.to_i
  31. end
  32.  
  33. end
  34.  
  35. puts product
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement