python script

i need to create a python script which modifies plaxis input through a txt file contains the commands

example: 


_gotostructures
sps sand "gammaunsat" %ZM.gammaunsat=18.5% "gammasat" %ZM.gammasat=18.5%
sps sand "phi" %ZM.phi=30.0% "psi" %ZM.phi=30.0%