Run shell command with variable in filename via Python -


i have files naming convention

st009_out.abc1.dat st009_out.abc2.dat st009_out.abc3.dat  .................. .................. 

i writing python code want use data file perform math function , need extract second column file. have tried way:

for k in range(1,10):     file1=open('st009_out.abc'+str(k)+'.dat','r')     ...........     os.system("awk '{print $2}' st009_out.abc${k}.pmf > raj.dat") 

but not working not taking value of k in shell command.

how progress?

try

os.system("awk '{print $2}' st009_out.abc"+str(k)+".pmf > raj.dat") 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -