def bin(args):
    """
    %prog bin data.tsv

    Conver tsv to binary format.
    """
    p = OptionParser(bin.__doc__)
    p.add_option("--dtype", choices=("float32", "int32"),
                 help="dtype of the matrix")
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    tsvfile, = args
    dtype = opts.dtype
    if dtype is None:  # Guess
        dtype = np.int32 if "data" in tsvfile else np.float32
    else:
        dtype = np.int32 if dtype == "int32" else np.float32

    print("dtype: {}".format(dtype), file=sys.stderr)
    fp = open(tsvfile)
    next(fp)
    arrays = []
    for i, row in enumerate(fp):
        a = np.fromstring(row, sep="\t", dtype=dtype)
        a = a[1:]
        arrays.append(a)
        print(i, a, file=sys.stderr)

    print("Merging", file=sys.stderr)
    b = np.concatenate(arrays)
    print("Binary shape: {}".format(b.shape), file=sys.stderr)
    binfile = tsvfile.rsplit(".", 1)[0] + ".bin"
    b.tofile(binfile)
%prog bin data.tsv

    Conver tsv to binary format.