Jan-10-2020, 08:58 AM
Hi,
I am new to Python and also new to this forum. Please forgive and correct me if you see any posting rules are violated in this post.
I am using Python version 3.8
I have a big XML file which contains the information about patient, service provider, insurance claim etc. This XML file contains many elements, nested child elements, attributes etc. in it. I want to convert this XML file into database table using Python script. This Python script should be able to read any number of XML file one by one and load data into DB table.
Below is the sample input XML file and output table
BEGIN
<?xml version="1.0" encoding="UTF-8"?>
<employee>
<fname>Christy</fname>
<lname>Charloette</lname>
<mail_address>
<add_line1>5052 Washington Street</add_line1>
<add_line2>Apt. 230</add_line2>
<city>New York</city>
<state>NY</state>
<zip_code>12345</zip_code>
<country>USA</country>
</mail_address>
<perm_address>
<add_line1>2598 Nolen Ave</add_line1>
<add_line2>Apt. 345</add_line2>
<city>New Jersy</city>
<state>NY</state>
<zip_code>54321</zip_code>
<country>USA</country>
</perm_address>
<expertise name="SQL"/>
<expertise name="Python"/>
<expertise name="Testing"/>
<expertise name="Business"/>
</employee>
Output table
------------
Elem_Key Elem_tag Value Parent_Elem
======== ======== ===== ===========
1001 employee
1002 fname Christy 1001
1003 lname Charloette 1001
1004 mail_address 1001
1005 add_line1 5052 Washing 1004
ton Street
1006 add_line2 Apt. 230 1004
1007 city New York 1004
1008 state NY 1004
1009 zip_code 12345 1004
1010 country USA 1004
1011 perm_address 1001
1012 add_line1 2598 Nolen Ave 1011
1013 add_line2 Apt. 345 1011
1014 city New Jersy 1011
1015 state NY 1011
1016 zip_code 54321 1011
1017 country USA 1011
1018 expertise SQL,Python, 1001
Testing,Busi
ness
END
Thanks!
I am new to Python and also new to this forum. Please forgive and correct me if you see any posting rules are violated in this post.
I am using Python version 3.8
I have a big XML file which contains the information about patient, service provider, insurance claim etc. This XML file contains many elements, nested child elements, attributes etc. in it. I want to convert this XML file into database table using Python script. This Python script should be able to read any number of XML file one by one and load data into DB table.
Below is the sample input XML file and output table
BEGIN
<?xml version="1.0" encoding="UTF-8"?>
<employee>
<fname>Christy</fname>
<lname>Charloette</lname>
<mail_address>
<add_line1>5052 Washington Street</add_line1>
<add_line2>Apt. 230</add_line2>
<city>New York</city>
<state>NY</state>
<zip_code>12345</zip_code>
<country>USA</country>
</mail_address>
<perm_address>
<add_line1>2598 Nolen Ave</add_line1>
<add_line2>Apt. 345</add_line2>
<city>New Jersy</city>
<state>NY</state>
<zip_code>54321</zip_code>
<country>USA</country>
</perm_address>
<expertise name="SQL"/>
<expertise name="Python"/>
<expertise name="Testing"/>
<expertise name="Business"/>
</employee>
Output table
------------
Elem_Key Elem_tag Value Parent_Elem
======== ======== ===== ===========
1001 employee
1002 fname Christy 1001
1003 lname Charloette 1001
1004 mail_address 1001
1005 add_line1 5052 Washing 1004
ton Street
1006 add_line2 Apt. 230 1004
1007 city New York 1004
1008 state NY 1004
1009 zip_code 12345 1004
1010 country USA 1004
1011 perm_address 1001
1012 add_line1 2598 Nolen Ave 1011
1013 add_line2 Apt. 345 1011
1014 city New Jersy 1011
1015 state NY 1011
1016 zip_code 54321 1011
1017 country USA 1011
1018 expertise SQL,Python, 1001
Testing,Busi
ness
END
Thanks!