I'm working on a python program that reads a text file, splits the file by semicolon, and then removes tabs and newlines. This is the code I have so far
myfile="F:\\Python\\Programs\\test.sas"
f=open(myfile,"r")
g=f.read()
statements=g.split(';')
statements.pop()
statements2=list()
for cue in statements:
statements2.append(cue.strip("\n")
print(statements)
The text file it reads looks like this
data test1;
set test;
run;
data test2;
set test;
run;
data test3;
set test2;
run;
data test4;
set test3;
run;
I'm just starting to learn python so I'm not really sure where the problem is. The error I'm getting has an arrow pointing at the t in print, and says "SyntaxError: invalid syntax"
I'm using python 3.4.3. Any help is greatly appreciated.
statements2.append(cue.strip("\n")you forgot to put closing bracket it should bestatements2.append(cue.strip("\n")).g.replace('\n', '')right after reading file