Skip to main content

Posts

Showing posts with the label Deep Learning

How parse XML file Dataset using python

Parse XML file and Store data in CSV file for machine learning Algorithms. import xml.etree.ElementTree as ET import os import csv path = 'G:\salman' with open('names.csv', 'a') as csvfile:     fieldnames = ['pair_id', 'e1', 'e2', 'Sentance']     writer = csv.DictWriter(csvfile, fieldnames=fieldnames)     for filename in os.listdir(path):         if not filename.endswith('.xml'): continue         fullname = os.path.join(path, filename)         tree = ET.parse(fullname)         lst = tree.findall('sentence')         for i in lst:             i_ = i.findall('pair')             for elem in i_:                 if elem.attrib['ddi'] == 'true':                     writer.writerow({'pair_id': elem.att...