Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

XML to CSV conversion

$
0
0

@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 copyfile

annotations = 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 += 1

data = 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

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles