Last active
March 7, 2016 23:34
-
-
Save aferriss/c62ae3fe7d6c6611f248 to your computer and use it in GitHub Desktop.
Formatting bad processing docs.
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 sys | |
import re | |
from BeautifulSoup import BeautifulSoup | |
def processFile(filename): | |
print "reading and writing from: " + str(filename) | |
file = open(filename, "r+") | |
#lines = file.readlines() | |
#lines.insert(-1, "-->") | |
handler = open(filename).read() | |
soup = BeautifulSoup(handler) | |
txt = '</description>' | |
head, sep, tail = str(soup).partition(txt) | |
newText = head + sep + '\n</root>' | |
#file.writelines(newText) | |
h, s, t = str(filename).partition('oldXml/') | |
newFile = open('edited/'+t, 'a') | |
newFile.writelines(newText) | |
print newText | |
processFile(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment