Skip to content

Instantly share code, notes, and snippets.

@jinjagit
Last active December 15, 2021 14:04
Show Gist options
  • Save jinjagit/ae6a5083ba12f0a5b10d28d754151ce1 to your computer and use it in GitHub Desktop.
Save jinjagit/ae6a5083ba12f0a5b10d28d754151ce1 to your computer and use it in GitHub Desktop.
Useful template for file sanitization needs
# Strips single quotes from a file, line by line.
# Useful template for other sanitization needs.
lines =[]
File.readlines('some_file.csv').each do |line|
lines << line
end
File.open("some_file.csv", "w") { |f|
lines.each do |line|
f << line.gsub("'", "")
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment