For some reason a script that always worked is now failing :( I investigated and trimmed down to something minimal, still not working:
cat a.py:
import sys
for row in sys.stdin.readlines():
print("hey")
print(row)
Testing:
>> cat b.csv
a,b,c
1,2,3
>> cat b.csv | python a.py
// hangs for ever, if I Ctrl+C:
for row in sys.stdin.readlines():
KeyboardInterrupt
Any idea what could be going on? Thanks!
After investigation, it looks like it has to do with the aliases I use.
Because I have different libraries for python2 and 3 I had
pythonpath2=/usr/local/lib/python2.7/site-packages
pythonpath3=~/Library/Python/3.6/lib/python/site-packages:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
alias p="unset PYTHONPATH; export PYTHONPATH=${pythonpath3}; python3.7"
alias p2="unset PYTHONPATH; export PYTHONPATH=${pythonpath2}; echo $PYTHONPATH; python"
So I guess before piping in the terminal would pipe into the last command of the alias and a change made it pipe into the first command of the alias (unset) which made it ineffective
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With