0

I'm able to write a single csv to an XML, but I want to take multiple csv files and put all of the data into a single xml.

The code I'm using to convert a single csv to a single xml is:

f = open('Final Mission Arvada Import\Import Files\Client_Final.csv')
csv_f = csv.reader(f)
next(csv_f, None)
data = []

for row in csv_f:
    data.append(row)
f.close()

def convert_row(row):
    return """
      <hmis:Client hmis:dateCreated="%s" hmis:dateUpdated="%s" hmis:userID="%s">
        <hmis:PersonalID>%s</hmis:PersonalID>
        <hmis:FirstName hmis:hashStatus="1">%s</hmis:FirstName>
        <hmis:MiddleName hmis:hashStatus="1">%s</hmis:MiddleName>
        <hmis:LastName hmis:hashStatus="1">%s</hmis:LastName>     
      </hmis:Client>""" % (row[1],row[2],row[3],row[4],row[5],row[6],row[7])

with open('Client.xml', 'w') as f:
    f.write('\n'.join([convert_row(row) for row in data]))

how can I then add additional information to the same xml from another csv?

john_207
  • 1
  • 1

0 Answers0