XML row count using python
# import required module
import os
import xml.etree.ElementTree as ET
# assign directory
directory = 'D:\\XML\\Data'
# iterate over files in
# that directory
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
# checking if it is a file
if os.path.isfile(f):
tree = ET.parse(f)
root = tree.getroot()
num_rows = len(root.findall('.//Product'))
print(f, num_rows)
Comments
Post a Comment