I’m trying to read the entries in a logfile so I can enter its contents
in a database, the lines are results I want to record, but in order to
be sure that I don’t have duplicates I’d like to be able to remove
entries that I have read. Is there an easy way to do this in Ruby so I
can remove read lines from a file that is open once they’ve been
I’m not as worried about the conn_to_db.print line, that is something I
have working ok, so if it looks funny please ignore it.
What I have so far, and its untested as of yet as I am trying to get the
form right, until I am sure its working .
read file into an array
f = file.open(“mylogfile.log”)
saved = File.open(“archive.log”, “a”)
results = f.readlines
Is there a way to remove everything that’s been read here?
results.each_line do |sending|
# Make sure we keep a backup
Close the archive file
Thanks for any help!