def trim(state)
open(state + "-cleaned.txt", "w") do |out|
IO.foreach(state + ".txt") do |line|
# The next line will show control characters.
p line
out.puts line.strip
end
end
end
outputs:
"Yorba Linda\240\240\n"
"Yountville \n"
"Yreka\240\240\n"
"Yuba City\240\240\n"
"Yucaipa\240\240\n"
"Yucca Valley "
=> nil
but alas the generated file still has trailing whitespaces. What should
I do to remove the \240 and \n? Is that not what strip! does?
--
Posted via http://www.ruby-forum.com/.