Newbi: Save console commands as script (e.g. rake task?)

Hello,

I am new to ruby but I am already with love with the console. What I am
looking for is a way, to write a parser that reads a text file and
creates database entries from it.

Something like:

for line in lines
p= Product.new
p.name=line
p.save
end