@neela27 wrote:
Hello I was following the article " A Practical Implementation of the Faster R-CNN Algorithm for Object Detection (Part 2 – with Python codes)" and had a problem converting xml to csv
I used the code that Pulkit Sir has provided
import os, sys, random
import xml.etree.ElementTree as ET
from glob import glob
import pandas as pd
from shutil import copyfileannotations = glob(‘D:\NeelaCSE\Thesis\BCCD_Dataset-master\BCCD\Annotations\*.xml’)
df =
cnt = 0
for file in annotations:
prev_filename = file.split(’/’)[-1].split(’.’)[0] + ‘.jpg’
filename = str(cnt) + ‘.jpg’
row =
parsedXML = ET.parse(file)
for node in parsedXML.getroot().iter(‘object’):
blood_cells = node.find(‘name’).text
xmin = int(node.find(‘bndbox/xmin’).text)
xmax = int(node.find(‘bndbox/xmax’).text)
ymin = int(node.find(‘bndbox/ymin’).text)
ymax = int(node.find(‘bndbox/ymax’).text)row = [prev_filename, filename, blood_cells, xmin, xmax,
ymin, ymax]
df.append(row)
cnt += 1data = pd.DataFrame(df, columns=[‘prev_filename’, ‘filename’, ‘cell_type’,
‘xmin’, ‘xmax’, ‘ymin’, ‘ymax’])data[[‘filename’, ‘cell_type’, ‘xmin’, ‘xmax’, ‘ymin’, ‘ymax’]].to_csv
i have no error in here but i dont think my csv file has generated. where will i find my converted csv file. I am new to this , help will be appreciated
Posts: 1
Participants: 1