The usage of this Python program is:
python ~/test.py test.txt
Here is the source:
import sys
#Open file passed by terminal
if len(sys.argv)==2:
try:
open(sys.argv[1])
with open(sys.argv[1]) as inputfile:
#Iterate through lines
for line in inputfile:
#tokenize
words=line.split()
#print tokens separated by commas
print(",".join(words))
inputfile.close
sys.exit(0)
except:
sys.exit(-1)
sys.exit(-1)
This is the "test.txt"
\ / input(" ")
input(print("some text"))
one two three
other things here
more stuff on this line
garbage
\n
%20
and it should output (which it does):
\,/,input(",")
input(print("some,text"))
one,two,three
other,things,here
more,stuff,on,this,line
garbage
\n
%20
But I'm wondering if there is some unexpected way to break it. Is there a way to nest carriage returns or something somewhere? Oh, and I realize that I can accomplish the same thing with:
print(",".join(line.split()))
But for this specific instance, I would like to separate the two steps.