User Tools

Site Tools


python_cli

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
python_cli [2021/02/07 16:19] rajupython_cli [2021/02/28 05:52] raju
Line 3: Line 3:
 get_column_names.py $filename | grep -i coupon | \ get_column_names.py $filename | grep -i coupon | \
 python -c "import sys; print(','.join(line.strip() for line in sys.stdin))" python -c "import sys; print(','.join(line.strip() for line in sys.stdin))"
 +</code>
 +
 +==== sort lines by length ====
 +<code>
 +import fileinput
 +print("".join(sorted(fileinput.input(), key=len)))
 +</code>
 +
 +On the command line:
 +<code>
 +% cat random_snippets.txt | python -c 'import fileinput; print("".join(sorted(fileinput.input(), key=len)))'
 +</code>
 +
 +Ref:- https://stackoverflow.com/questions/34401683/how-to-use-awk-to-sort-lines-by-length/
 +
 +==== sql string in clause ====
 +<code>
 +cat junk3.txt | \
 +python -c "import sys; print('\'', '\', \''.join(line.strip() for line in sys.stdin), '\'', sep='')"
 </code> </code>
  
python_cli.txt · Last modified: 2021/02/28 06:27 by raju