Created
February 24, 2013 05:02
-
-
Save tmaybe/5022681 to your computer and use it in GitHub Desktop.
Simple Python script for reading from a file, changing something about it with a regular expression, and writing the result to a new file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
read_in = open("original.plist") | |
write_out = open("new.plist","w") | |
minus = 280 | |
pat = re.compile('\t\t\t\t<real>([0-9]*)<') | |
for line in read_in: | |
mo = pat.search(line) | |
if mo: | |
value = int(mo.group(1)) | |
writeme = "\t\t\t\t<real>" + str(value - minus) + "</real>\n" | |
write_out.write(writeme) | |
else: | |
write_out.write(line) | |
read_in.close() | |
write_out.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment