Created
June 4, 2013 19:31
-
-
Save bradland/5708806 to your computer and use it in GitHub Desktop.
Cleans up CSV files
This file contains 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
#!/usr/bin/env ruby | |
require 'csv' | |
require 'iconv' | |
def clean(string) | |
# Tranlit to ASCII | |
string = Iconv.new('ASCII//TRANSLIT', 'UTF-8').iconv(string) | |
# Trim whitepsace | |
string = string.chomp | |
# Return the cleaned up string | |
string | |
end | |
CSV.foreach(File.expand_path(ARGV[0])) do |line| | |
puts line.map!{|i| clean(i)}.to_csv | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment