code: def create_new_csv(samples, args):
      
      out_fn = os.path.splitext(args.csv)[0] + "-merged.csv"
      logger.info("Preparing new csv: %s" % out_fn)
      with file_transaction(out_fn) as tx_out:
          with open(tx_out, 'w') as handle:
              handle.write(_header(args.csv))
              for s in samples:
                  sample_name = s['name'] if isinstance(s['out_file'], list) else os.path.basename(s['out_file'])
                  handle.write("%s,%s,%s\n" % (sample_name, s['name'], ",".join(s['anno'])))
docs: create csv file that can be use with bcbio -w template