Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. options = {:encoding => 'UTF-8', :skip_blanks => true}
  2. CSV.foreach("data.csv", options, ) do |row, i|
  3. puts i
  4. end
  5.  
  6. require 'csv'
  7.  
  8. CSV.foreach('test.csv') do |csv|
  9. puts $.
  10. end
  11.  
  12. Year,Make,Model,Description,Price
  13. 1997,Ford,E350,"ac, abs, moon",3000.00
  14. 1999,Chevy,"Venture ""Extended Edition""","",4900.00
  15. 1999,Chevy,"Venture ""Extended Edition, Very Large""","",5000.00
  16. 1996,Jeep,Grand Cherokee,"MUST SELL!nair, moon roof, loaded",4799.00
  17.  
  18. 1
  19. 2
  20. 3
  21. 4
  22. 5
  23.  
  24. require 'english'
  25.  
  26. puts $INPUT_LINE_NUMBER
  27.  
  28. options = {:encoding => 'UTF-8', :skip_blanks => true}
  29.  
  30. CSV.read("data.csv", options).each_with_index do |row, i|
  31. puts i
  32. end
  33.  
  34. options = {:encoding => 'UTF-8', :skip_blanks => true}
  35. i = 0
  36. CSV.foreach("data.csv", options) do | row |
  37. puts i
  38. i += 1
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement