Skip to content

Instantly share code, notes, and snippets.

@marceldegraaf
Created June 5, 2009 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marceldegraaf/124313 to your computer and use it in GitHub Desktop.
Save marceldegraaf/124313 to your computer and use it in GitHub Desktop.
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