Skip to content

Instantly share code, notes, and snippets.

@ishu3101
Created July 6, 2016 00:42
Show Gist options
  • Save ishu3101/1e9bdf7e0cb28347e312ba0759fa5916 to your computer and use it in GitHub Desktop.
Save ishu3101/1e9bdf7e0cb28347e312ba0759fa5916 to your computer and use it in GitHub Desktop.
Read input either from stdin or as command line argument using Python.
import sys
import fileinput
for line in fileinput.input(sys.argv[1:]):
print line.strip().upper()
abc efg hij
klm nop qrs
tuv wxy zab

Usage

python stdin.py filename.csv
cat filename.csv | python stdin.py

Output

ABC,EFG,HIJ
KLM,NOP,QRS
TUV,WXY,ZAB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment