code: def fromcsv(args):
      
      from csv import reader
      from xlwt import Workbook, easyxf
      from jcvi.formats.base import flexible_cast
  
      p = OptionParser(fromcsv.__doc__)
      p.add_option("--noheader", default=False, action="store_true",
                   help="Do not treat the first row as header")
      p.add_option("--rgb", default=-1, type="int",
                   help="Show RGB color box")
      p.set_sep()
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      csvfile, = args
      header = not opts.noheader
      rgb = opts.rgb
      excelfile = csvfile.rsplit(".", 1)[0] + ".xls"
  
      data = []
      for row in reader(open(csvfile), delimiter=opts.sep):
          data.append(row)
  
      w = Workbook()
      s = w.add_sheet(op.basename(csvfile))
  
      header_style = easyxf('font: bold on')
      if header:
          s.panes_frozen = True
          s.horz_split_pos = 1
  
      cm = ColorMatcher()
      for i, row in enumerate(data):
          for j, cell in enumerate(row):
              cell = flexible_cast(cell)
              if header and i == 0:
                  s.write(i, j, cell, header_style)
              else:
                  if j == rgb:
                      cix = cm.match_color_index(cell)
                      color_style = easyxf('font: color_index {0}'.format(cix))
                      s.write(i, j, cell, color_style)
                  else:
                      s.write(i, j, cell)
  
      w.save(excelfile)
      logging.debug("File written to `{0}`.".format(excelfile))
      return excelfile
docs: %prog fromcsv csvfile
  
      Convert csv file to EXCEL.