Created
June 5, 2009 14:46
-
-
Save marceldegraaf/124313 to your computer and use it in GitHub Desktop.
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
namespace :csv do | |
desc "Makes sure all rows have a trailing ;" | |
task :cleanup do | |
file, new_file = ENV['FILE'], ENV['NEWFILE'] | |
raise "Provile valid FILE and NEWFILE, e.g. FILE=./lib/prospects.csv" unless file or new_file | |
lines, new_file = File.open(file), File.open(new_file, 'wb') | |
lines.each_line do |line| | |
unless line.strip.last == ";" | |
line = line.strip + ";#{$/}" | |
end | |
new_file << line | |
end | |
new_file.close | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment