Archive for December, 2008
Ruby file loading
10 December 2008Just coz I always forget them, three good ways to load files into memory in ruby
File.open(filename, ‘r’) do |f| f.readlines end
IO.readlines(filename).each do |line| end
lines = IO.read(filename).split(”n”)
thanks to Partro for the outline along with the following three points
File.open gives you a file handle you can stream from
while the IO methods read it all in at […]