<commit_before>__author__ = 'William'
import csv
import sys
import re

xmloutput = ""
root = ""
element = ""
attributes = []
opentag = '<'
closetag = '>'


def loadFile(filename):
    file = open(filename)
    try:
        reader = csv.reader(file)
        extractHeadings(reader)
    finally:
        file.close()


def extractHeadings(reader):
    global root, element, attributes
    select = reader.next()
    root = re.sub(r'\W+', '', select[0])
    element = re.sub(r'\W+', '', select[1])
    select = reader.next()
    attributes = select
    buildxml(reader)


def buildxml(reader):
    global xmloutput
    xmloutput += opentag + root + closetag  #<root>
    #<attributes>
    for row in reader:
        buildAttributes(row)
    xmloutput += '\n' + opentag + '/' + root + closetag  #</root>


def buildAttributes(row):
    global xmloutput
    xmloutput += '\n\t' + opentag + element + closetag  #<element>
    for i in range(len(attributes)):
        attribute = re.sub(r'\W+', '', attributes[i])
        xmloutput += '\n\t\t' + opentag + attribute + closetag + row[i] + opentag + '/' + attribute + closetag
    xmloutput += '\n\t' + opentag + '/' + element + closetag  #</element>


def saveToFile(filename):
    text_file = open(filename, 'w')
    text_file.write(xmloutput)
    text_file.close()


if __name__ == '__main__':
    loadFile(str(sys.argv[1]))
    saveToFile(sys.argv[2])
    #print xmloutput<commit_msg>remove misleading comment from code<commit_after>__author__ = 'William'
import csv
import sys
import re

xmloutput = ""
root = ""
element = ""
attributes = []
opentag = '<'
closetag = '>'


def loadFile(filename):
    file = open(filename)
    try:
        reader = csv.reader(file)
        extractHeadings(reader)
    finally:
        file.close()


def extractHeadings(reader):
    global root, element, attributes
    select = reader.next()
    root = re.sub(r'\W+', '', select[0])
    element = re.sub(r'\W+', '', select[1])
    select = reader.next()
    attributes = select
    buildxml(reader)


def buildxml(reader):
    global xmloutput
    xmloutput += opentag + root + closetag  #<root>
    for row in reader:
        buildAttributes(row)
    xmloutput += '\n' + opentag + '/' + root + closetag  #</root>


def buildAttributes(row):
    global xmloutput
    xmloutput += '\n\t' + opentag + element + closetag  #<element>
    for i in range(len(attributes)):
        attribute = re.sub(r'\W+', '', attributes[i])
        xmloutput += '\n\t\t' + opentag + attribute + closetag + row[i] + opentag + '/' + attribute + closetag
    xmloutput += '\n\t' + opentag + '/' + element + closetag  #</element>


def saveToFile(filename):
    text_file = open(filename, 'w')
    text_file.write(xmloutput)
    text_file.close()


if __name__ == '__main__':
    loadFile(str(sys.argv[1]))
    saveToFile(sys.argv[2])
    #print xmloutput
{'fraction_non_alphanumeric': 0.15478686233403213, 'fraction_numerical': 0.002795248078266946, 'mean_word_length': 3.021067415730337, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2585072', 'n_tokens_mistral': 970, 'n_tokens_neox': 952, 'n_words': 222}