I have a file that looks something like this:
o 345644 0 0 0 1
0 454545 0 0 2 2
0 423233 0 0 1 1
. . . . . .
. . . . . .
. . . . . .
What I would like to do is extract column two and column 6 to create a text file. I wrote the following code but the output file I am getting only contains the second column. The desired output I am would like is a new file that looks like this:
newfile.txt
345644 1
454545 2
423233 1
. .
. .
. .
Here is my code :
dta_2path = open("file.txt","r")
ws_2= open("newfile.txt", "w")
for line in dta_2path:
if line.strip():
ws_2.write("\t".join(line.split()[1:2]+ line.split()[9:10])+"\n")
dta_2path.close()
ws_2.close()
Any help in how to fix this would be appreciated. Thanks in advance!
line.split()[1]andlines.split()[5]?