I am trying to get input from a file, through cat command, into a python file. My python version is 3.5. The code looks like this.
with open(sys.argv[1]) as f:
while True:
if f.readline()== '':
break
line = f.readline().strip()
And i am getting the input through the following command.
python cptest.py | cat ts.csv
But i keep running into the following error.
File "cptest.py", line 9, in with open(sys.argv[1]) as f: IndexError: list index out of range
How can i send input to a python script from a file using cat command? I have to use cat command, or any other way i can pipe the input to the file.