UsageΒΆ

To use pyline in a project:

import pyline

To use pyline as a shell command:

$ pyline --help
Usage: pyline [-f<path>] [-o|--output-file=<path>] 
              [-F|--input-delim='\t'] 
              [--input-delim-split-max=3] 
              [-d|--output-delimiter='||'] 
              [-n|--number-lines] 
              [-m|--modules=<mod2>] 
              [-p|--pathpy] [--pathlib] 
              [-r '<rgx>'|--regex='<rgx>'] 
              '<commandstr>'

Pyline is a UNIX command-line tool for line-based processing in Python with
regex and output transform features similar to grep, sed, and awk.

Options:
  -h, --help            show this help message and exit
  -f FILE               Input file  #default: '-' for stdin
  -F IDELIM, --input-delim=IDELIM
                        words = line.split(-F)  #default: None (whitespace)
  --max=IDELIM_SPLIT_MAX, --input-delim-split-max=IDELIM_SPLIT_MAX
                        words = line.split(-F, --max)
  --shlex               words = shlex.split(line)
  -o OUTPUT, --output-file=OUTPUT
                        Output file  #default: '-' for stdout
  -d ODELIM, --output-delim=ODELIM
                        String output delimiter for lists and tuples
                        #default: '\t' (tab, chr(9), $'\t')
  -O OUTPUT_FILETYPE, --output-filetype=OUTPUT_FILETYPE
                        Output filetype <txt|csv|tsv|json|checkbox|html>
                        #default: txt
  -p, --pathpy          p = path.Path(line); import path   #pip install
                        path.py
  --pathlib             p = pathlib.Path(line); import pathlib
  -r REGEX, --regex=REGEX
                        rgx = re.compile(-r).match(line)
  -R REGEX_OPTIONS, --regex-options=REGEX_OPTIONS
                        Regex options: I L M S X U (ref: `$ pydoc re`)
  --cols=COL_MAPSTR     Optional column mappings (4::int, 0::unicode)
  -s SORT_ASC, --sort-asc=SORT_ASC
                        sorted(lines, key=itemgetter(*-s))
  -S SORT_DESC, --sort-desc=SORT_DESC
                        sorted(lines, key=itemgetter(*-S), reverse=True)
  -n, --number-lines    Print line numbers of matches
  -m MODULES, --modules=MODULES
                        for m in modules: import m  #default: []
  -i, --ipython         Start IPython with results
  -v, --verbose         
  -q, --quiet