Skip to content

Instantly share code, notes, and snippets.

@tkb77
Created June 13, 2015 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkb77/0b08cc15ecffe4f315ea to your computer and use it in GitHub Desktop.
Save tkb77/0b08cc15ecffe4f315ea to your computer and use it in GitHub Desktop.
parameterPermutater
#ログデータを書き換えるスクリプト
#変更するファイルのアドレス
editFileName = 'data'
#変更する内容
permutString = 'x 0.0'
#変更するパラーメータの文字列
targetString = 'x'
#変更するファイルを読み込む
editfile = open(editFileName,'r')
lines = editfile.readlines()
editfile.close()
#パラーメータの書き換え
for i,line in enumerate(lines):
if line.count(targetString):
lines[i] = permutString + '\n'
#書き換えたファイルの出力
saveFileName = "Permuted_" + editFileName
savefile = open(saveFileName,'w')
savefile.writelines(lines)
savefile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment