I need to replace ” for ‘ in all csv files in one directory. I wonder if there is either
- nice one line piece of code to do that or
- if I use the
fastestway to solve what I do
My code is
files = Dir["*.csv"]
files.each do |file_name|
File.open(file_name, "w") {|file|
file.puts File.read(file_name).gsub('"', "'")
}
end
update
- ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
- I prefer ruby only solution
You can edit the files in place like so: