Created
October 9, 2012 21:58
-
-
Save jeffreybaird/3861705 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'csv' | |
| def remove_dupes | |
| uniq_csv = [] | |
| CSV.foreach("input.csv","r+") {|csv| uniq_csv << csv } | |
| uniq_csv.uniq!.compact.compact | |
| end | |
| CSV.open("ouput.csv","w+") do |csv| | |
| remove_dupes.each { |entry| csv << entry } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the source CSV isn't too large, could you have just done:
(I don't know your data so the #compact and perhaps the double #compact is required)
Also, there is no reason to use the self modifying version "uniq!" where I think you more mean the returning version of "uniq"