Exemple #1
0
def doMain():
    args = parseOpts(sys.argv[1:])

    convIdxL = pysows.getTypedColumnIndexList(args.group_indexes)

    g = globals()
    l = locals()
    pysows.loadPythonCodeFile(args.load_file, g, l)
    keyFunc = generateKeyFunc(args.key_func, g, l)
    reader = sortKeyAndLineGenerator(convIdxL, keyFunc, sys.stdin, args.separator)

    for sortKey, line in sorted(reader, key=lambda (x,y):x, reverse=args.reverse):
        print line
Exemple #2
0
def doMain():
    args = parseOpts(sys.argv[1:])

    g = globals()
    l = locals()
    pysows.loadPythonCodeFile(args.load_file, g, l)
    mapFunc = eval(args.map_func, g, l)
    constructor = eval(args.record_constructor, g, l)

    convIdxL = pysows.getTypedColumnIndexList(args.group_indexes)
    assert len(convIdxL) > 0
    getKeyFromRec = pysows.generateProjectConv(convIdxL)

    reader = pysows.recordReader(sys.stdin, args.separator)

    for rec in reader:
        key = getKeyFromRec(rec)
        mapped = mapFunc(*key)
        outRec = constructor(rec, mapped)
        pysows.printList(outRec)
        print
Exemple #3
0
def doMain():
    args = parseOpts(sys.argv[1:])

    convIdxL = pysows.getTypedColumnIndexList(args.group_indexes)

    g = globals()
    l = locals()
    pysows.loadPythonCodeFile(args.load_file, g, l)

    if args.regex_list is None:
        filterBy = generateFilterByPredicate(args.predicate, convIdxL, g, l)
    else:
        filterBy = generateFilterByRegex(args.regex_list, convIdxL)
    if args.invert:
        notIfInvert = lambda x: not x
    else:
        notIfInvert = lambda x: x

    for rec in pysows.recordReader(sys.stdin, args.separator):
        if notIfInvert(filterBy(rec)):
            pysows.printList(rec)
            print