def mergecsv(args):
    p = OptionParser(mergecsv.__doc__)
    opts, args = p.parse_args(args)

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

    csvfiles = args
    arrays = []
    samplekeys = []
    for csvfile in csvfiles:
        samplekey = op.basename(csvfile).split(".")[0]
        a = np.fromfile(csvfile, sep=",", dtype=np.int32)
        x1 = a[::2]
        x2 = a[1::2]
        a = x1 * 1000 + x2
        a[a < 0] = -1
        arrays.append(a)
        samplekeys.append(samplekey)
        print >> sys.stderr, samplekey, a
    print >> sys.stderr, "Merging"
    b = np.concatenate(arrays)
    b.tofile("data.bin")

    fw = open("samples", "w")
    print >> fw, "\n".join(samplekeys)
    fw.close()
%prog mergecsv *.csv
dataset/ETHPy150Open tanghaibao/jcvi/variation/str.py/mergecsv