Skip to content

Instantly share code, notes, and snippets.

@sudevschiz
Created January 29, 2016 07:13
Show Gist options
  • Save sudevschiz/ef0d3647f9cdc1cd7ae6 to your computer and use it in GitHub Desktop.
Save sudevschiz/ef0d3647f9cdc1cd7ae6 to your computer and use it in GitHub Desktop.
Script to remove some unwanted character from a string. Basic string manipulation
out_file = open("out_file.txt","w")
with open('formulas.txt','r') as fil:
for lin in fil:
#Here, '+' is the unwanted character at the 0th position. Edit accordingly for other characters
if(lin[0] == "+"):
new_line = lin[1:]
print new_line
else:
new_line = lin
#Had to add a "dvs ~ " to each of my formulas in this case. Edit accordingly.
new_line = "dvs ~ " + new_line
new_form.write(new_line)
new_form.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment