code: 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(samplekey, a, file=sys.stderr)
      print("Merging", file=sys.stderr)
      b = np.concatenate(arrays)
      b.tofile("data.bin")
  
      fw = open("samples", "w")
      print("\n".join(samplekeys), file=fw)
      fw.close()
docs: %prog mergecsv *.csv
  
      Combine CSV into binary array.