Ruby: CSV to HTML

Quickly written code for conversion CSV to HTML.
It looks that using awk is a little bit more efficient,
however on the other hand - below code uses opens file
to write and handles input from command line (ARGV).

Following line:


Drops whitespaces, ", and last commas of every line. Then replaces
commas with </td><td>.

Source code

if ARGV.count < 1
  puts "Usage:"
  puts "  csv2html.rb <csv filename> [output filename]"
ifname = ARGV[0]
ofname = "a.out"
ofname = ARGV[1] if ARGV.count > 1
str = "<table>\n" # output string { |line|
  str += "  <tr><td>" + line.strip.gsub(/\"/,"").gsub(/,$/,"").gsub(/,/,"</td><td>") + "</td>\n"
str += "</table>", 'w') {|f| f.write(str) }