I've had a set of data which I want to deal with. I was trying to run a python code to execute "awk" command in linux. hoverver no matter how I try different arguments or functions, it all didn't work.
there are two different way in which I have tried, but they all didn't work. I don't know why
1)
#!/usr/bin/env python
import subprocess as sp
cmd = "awk, '{print $2 '\t' $4 '\t' $5 '\t' $6}', B3LYPD.txt"
args = cmd.split(',')
p = sp.Popen(args, stdin = sp.PIPE, stdout = sp.PIPE, stderr = sp.PIPE )
2)
#!/usr/bin/env python
import subprocess as sp
cmd = "awk, '{print $2 '\t' $4 '\t' $5 '\t' $6}'"
args = cmd.split(',')
p = sp.Popen(args, stdin = sp.PIPE, stdout = sp.PIPE, stderr = sp.PIPE )
c = p.communicate('B3LYPD.txt')
print c
shlex.splitnotstr.split.awk? Python probably can do everything you need fromawkjust fine.c = "this, that, other" ; args = cmd.split(','), you can just useargs = ["this", "that", "other"]and skip the split command.split()function to pick out columns, if your code here is representative of your actualawkpattern.