LOGIN
Sign In or Register
Avatar
Not Registered Yet?

Join Now! It's FREE. Get full access and benefit from this site

Reset My password - Remind Me My username

Username
Password
Remember me
× Ruby Programming

How to process every line in a text file with Ruby

More
2 years 1 month ago #2360 by scmuser
scmuser created the topic: How to process every line in a text file with Ruby
Example 1

# ruby sample code.
# process every line in a text file with ruby (version 1).
file='GettysburgAddress.txt'
File.readlines(file).each do |line|
puts line
end


Example 2

# ruby sample code.
# process every line in a text file with ruby (version 2).
file='GettysburgAddress.txt'
f = File.open(file, "r")
f.each_line { |line|
puts line
}
f.close


Source -
alvinalexander.com/blog/post/ruby/how-pr...-line-text-file-ruby

Please Log in to join the conversation.

Time to create page: 0.965 seconds