How to detect the last row in CSV (ruby)
<pre><code>data = IO::read(file).scrub("")
CSV.parse(data, {:col_sep =&gt; "\t", :headers =&gt; headers, :quote_char =&gt; '_'}) do |row|
  # how to detect last line of CSV?
end
</code></pre>

<p>I have a giant CSV file that needs to be scrubbed. It has multiple lines that apply to one DB object. In my code I'm collecting all the lines that apply to one object before passing them off to a class that will process them. </p>

<p>It would be very helpful if I could detect the last line in the CSV so I could make sure the last collection gets sent.</p>