I have already posted this question as Anonymous monk. Please delete my previous thread. I have registered and created this question again.
we have a CSV file which need be to converted to XML using Perl or Unix shell scripting. I was able to build this XML using SQL and Korn shell script. However, SQL/shell script is running for long time. Hence, I'm considering to write a Perl to generate this XML file. Basically need to build this XML hierarchically by avoiding the duplicate values. Please take a look into the CSV and XML file below. But the both SQL and Korn shell script takes 15 minutes to create the XML for just 6000 records. Please let me know if there is any other efficient way to process this CSV file. this CSV file contains total 20 million records. Need to build this XML file within 60 to 120 minutes. Appreciate your help. Input data below:-
RLTP_ID,RLTP_NAME,PROD_ID,PROD_NAME,CUST_ID,CUST_NAME,ACC_ID,ACC_NAME,
+ACC_BALANCE,TXN_ID,TXN_AMT,ACC_TYPE,ACC_CODE,TXN_CODE
10,Phil,1,Personal,2,Fixed,3,Savings,3000,4,500,X,YY,11
10,Phil,1,Personal,2,Fixed,3,Savings,3000,4,500,X,YY,12
10,Phil,1,Personal,2,Fixed,3,Savings,3000,4,500,X,ZZ,11
10,Phil,1,Personal,2,Fixed,3,Savings,3000,4,500,X,ZZ,12
10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,AA,11
10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,AA,12
10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,AA,13
10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,BB,11
10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,BB,12
10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,BB,13
Output XML
<transactiondetails>
<rltp_id>10</rltp_id>
<rltp_name>Phil</rltp_name>
<product>
<prod_id>1</prod_id>
<prod_name>Personal</prod_name>
<customer>
<cust_id>2</cust_id>
<cust_name>Fixed</cust_name>
<account>
<acc_id>3</acc_id>
<acc_name>Savings</acc_name>
<acc_balance>3000</acc_balance>
<acc_type>X</acc_type>
<acc_code>ZZ</acc_code>
<acc_code>YY</acc_code>
<transaction>
<txntrack>
<txn_id>4</txn_id>
<txn_amt>500</txn_amt>
<txn_code>11</txn_code>
<txn_code>12</txn_code>
</txntrack>
</transaction>
<transaction>
<txntrack>
<txn_id>5</txn_id>
<txn_amt>500</txn_amt>
<txn_code/>
</txntrack>
</transaction>
<transaction>
<txntrack>
<txn_id>6</txn_id>
<txn_amt>500</txn_amt>
<txn_code/>
</txntrack>
</transaction>
</account>
<account>
<acc_id>7</acc_id>
<acc_name>Savings</acc_name>
<acc_balance>3000</acc_balance>
<acc_type>X</acc_type>
<acc_code>AA</acc_code>
<acc_code>BB</acc_code>
<transaction>
<txntrack>
<txn_id>8</txn_id>
<txn_amt>500</txn_amt>
<txn_code>11</txn_code>
<txn_code>12</txn_code>
<txn_code>13</txn_code>
</txntrack>
</transaction>
</account>
</customer>
</product>
</transactiondetails>