csv with parent-child columns to xml
- From: billsahiker@xxxxxxxxx
- Date: Tue, 20 Nov 2007 12:56:42 -0800 (PST)
Can any of the commercial conversion tools convert csv files
containing "relational" data to xml in an automated fashion? I looked
at the websites for stylussudio and altova, but it looks like I would
have to do some xslt coding for each file. I don't mind filling in
some configuration forms for each project, I just don't want to have
to write code for each one. I have hundreds of these to do over the
next months. I wrote a c# program using an xmldocument, but it
requires a lot of hard coding for each project.
Each csv file has different columns but they all contain some parent-
child relationships. The xml structure for each file would be
different, but in all cases I need to have the child columns be xml
elements nested under xml elements corresponding to the parent
columns. The number of child elements varies. There are some files
with child elements that are also parents of other child elements,
nested many levels deep.
Below is a simple example.
Csv input file:
Department,Division,Firstname,Lastname
IT,Support,Sam ,Smith
IT,Support,Tom ,Jones
IT,Networks,Bill ,Thomas
IT,Networks,John ,English
IT,Networks,Taylor ,Temple
Accounting,Payroll,Sue ,Johnson
Accounting,Payroll,Larry ,Neilson
Accounting,Receivables,Harry ,Feldman
Accounting,Receivables,Stan ,Simon
Xml output file
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<Departments>
<Department>
<DepName>IT</DepName>
<Divisions>
<Division>
<DivisionName>Support</DivisionName>
<Employees>
<Employee>
<FirstName>Sam </FirstName>
<LastName>Smith</LastName>
</Employee>
<Employee>
<FirstName>Tom </FirstName>
<LastName>Jones</LastName>
</Employee>
</Employees>
</Division>
<Division>
<DivisionName>Networks</DivisionName>
<Employees>
<Employee>
<FirstName>Bill </FirstName>
<LastName>Thomas</LastName>
</Employee>
<Employee>
<FirstName>John </FirstName>
<LastName>English</LastName>
</Employee>
<Employee>
<FirstName>Taylor </FirstName>
<LastName>Temple</LastName>
</Employee>
</Employees>
</Division>
</Divisions>
</Department>
<Department>
<DepName>Accounting</DepName>
<Divisions>
<Division>
<DivisionName>Payroll</DivisionName>
<Employees>
<Employee>
<FirstName>Sue </FirstName>
<LastName>Johnson</LastName>
</Employee>
<Employee>
<FirstName>Larry </FirstName>
<LastName>Neilson</LastName>
</Employee>
</Employees>
</Division>
<Division>
<DivisionName>Receivables</DivisionName>
<Employees>
<Employee>
<FirstName>Harry </FirstName>
<LastName>Feldman</LastName>
</Employee>
<Employee>
<FirstName>Stan </FirstName>
<LastName>Simon</LastName>
</Employee>
</Employees>
</Division>
</Divisions>
</Department>
</Departments>
.
- Follow-Ups:
- Re: csv with parent-child columns to xml
- From: Andrew Brook
- Re: csv with parent-child columns to xml
- Prev by Date: Re: Xpath and Sorting
- Next by Date: RE: Can't access a System object in xaml
- Previous by thread: Xpath and Sorting
- Next by thread: Re: csv with parent-child columns to xml
- Index(es):
Relevant Pages
|