MOTOSHARE 🚗🏍️

Rent Bikes & Cars Directly from Owners

Motoshare connects vehicle owners with people who need bikes and cars on rent. Owners earn from idle vehicles, and renters get flexible ride options.

Visit Motoshare

How to process every line in a text file with Ruby

ruby programming

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x