Skip to content

Instantly share code, notes, and snippets.

@onriv
Created December 3, 2013 17:10
Show Gist options
  • Save onriv/7773180 to your computer and use it in GitHub Desktop.
Save onriv/7773180 to your computer and use it in GitHub Desktop.
Python:oarSimFileGen.py
#!/usr/bin/python
import os, sys, shutil, re
source_file = open(sys.argv[1])
source_name = sys.argv[1].rstrip(".egsinp")
dst_file1_name = source_name + "_colli50mm.egsinp"
dst_file2_name = source_name + "_colli40mm.egsinp"
dst_file3_name = source_name + "_colli30mm.egsinp"
dst_file4_name = source_name + "_colli25mm.egsinp"
dst_file1 = open(dst_file1_name,'w')
dst_file2 = open(dst_file2_name,'w')
dst_file3 = open(dst_file3_name,'w')
dst_file4 = open(dst_file4_name,'w')
for src in source_file:
tmp1 = re.sub("CyberKnife_7p2_60cm_added.egsphsp1","CyberKnife_7p2_60cm_colli50mm_added.egsphsp1",src)
tmp2 = re.sub("CyberKnife_7p2_60cm_added.egsphsp1","CyberKnife_7p2_60cm_colli40mm_added.egsphsp1",src)
tmp3 = re.sub("CyberKnife_7p2_60cm_added.egsphsp1","CyberKnife_7p2_60cm_colli30mm_added.egsphsp1",src)
tmp4 = re.sub("CyberKnife_7p2_60cm_added.egsphsp1","CyberKnife_7p2_60cm_colli25mm_added.egsphsp1",src)
print >> dst_file1, tmp1,
print >> dst_file2, tmp2,
print >> dst_file3, tmp3,
print >> dst_file4, tmp4,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment