What is the best approach to deal with complex row based object hierarchy in CSV or Excel file in importing into DB?
eg. We have the following CSV or Excel data (Pipe delimited and \r\n separate a new row):
START|\r\n
MEMBER|Mr|John|Lee|\r\n
INSURANCE|2015-1-15|LIFE|\r\n
END|\r\n
START|\r\n
MEMBER|Ms|Mary|Scott|\r\n
INSURANCE|2015-1-10|LIFE|\r\n
END|\r\n
....
....
Here each START/END marks one record. The final goal is to transform it into an XML like this:
<Members>
<Member>
<Title>Mr<\Title>
<FN>John<\FN>
<LN>Lee<\LN>
<Insurance>
<Join_Date>2015-1-10<\Join_Date>
<Category>Life<\Category>
<\Insurance>
<\Member>
...
<Member>
...
<\Member>
<\Members>
Thanks for any input.