Skip to content

Latest commit

 

History

History
59 lines (41 loc) · 761 Bytes

examples.rst

File metadata and controls

59 lines (41 loc) · 761 Bytes

Examples

Sort

$ spy -mc sorted < test.txt
file
five
has
lines
this

Filter

$ spy -l -f 'len(pipe) == 4' < test.txt
this
file
five

Enumerate

Naively:

$ spy -m "['{}: {}'.format(n, v) for n, v in enumerate(pipe, 1)]" < test.txt
1: this
2: file
3: has
4: five
5: lines

Taking advantage of spy piping:

$ spy -m 'enumerate(pipe, 1)' "'{}: {}'.format(*pipe)" < test.txt
1: this
2: file
3: has
4: five
5: lines

Convert CSV to JSON

$ spy -c csv.DictReader -c list -c json.dumps < thing.csv > thing.json