Want to parse an xml file and write into a CSV file



I'm new to using python (just learning). My task that I'm trying to complete using python is: To parse thru many xml files in 1 folder - the structure is the same for each xml file. I would like to write all of this data to 1 large csv file. The header of the CSV file would be the attributes of the xml files.


Here is a sample of 1 of the xml files:



<?xml version='1.0' encoding='UTF-8' ?>
<XACTDOC>
<XACTNET_INFO
transactionId = "0254XLM"
origTransactionId = "0254XLM"
carrierExternalUniqueId = "6533277"
carrierId = "2570210"
carrierName = "Company_Name"
contractorName = "ContractorSoenSo"
recipientsXNAddress = "text"
recipientsName = "moreText"
>
<CONTROL_POINTS>
<CONTROL_POINT
stamp = "2014-10-20T16:02:08"
createdStamp = "2014-10-20T16:02:08"
type = "Notification Pending"
status = "2"
/>
</CONTROL_POINTS>
</XACTNET_INFO>
<CONTACTS/>
<ADM>
<COVERAGE_LOSS
claimNumber = "123456-78"
/>
</ADM>
</XACTDOC>


Any help you could offer would be great!


No comments:

Post a Comment