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
Last revisionBoth sides next revision
python_cli [2021/02/12 20:42] – [sql string in clause] rajupython_cli [2021/02/28 05:52] raju
Line 4: Line 4:
 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> </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 ==== ==== sql string in clause ====
python_cli.txt · Last modified: 2021/02/28 06:27 by raju