Python Forum
Multiple XML file covert to CSV output file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple XML file covert to CSV output file
#1
Hi Team,
I have a multiple XML file and I want to convert the Multiple XML data into CVS file with | separator it is used to stored into the database.
Could you pls let me the code in python.
Sample multiple xml file:-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StandingSettlementInstruction xmlns="http://www.service.cdds.cs.com/ssiData_2">
<StableChangeVersion>2</StableChangeVersion>
<Core>
<LocalId>0171375670</LocalId>
<EffectiveDate>2018-06-24T06:38:47.093-04:00</EffectiveDate>
<DataStatus>Active</DataStatus>
<InternalIdentifier>00000000-0000-0000-0000-000008180d98</InternalIdentifier>
</Core>
<Change>
<LastApprovedVersion>2</LastApprovedVersion>
<LatestReviewTime>2018-06-24T06:38:47.013-04:00</LatestReviewTime>
</Change>
<SystemCodes>
<SystemCodeType>
<Id>NTPA</Id>
</SystemCodeType>
<Value>Y37F40</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
<LatestReviewers>
<userName>msiepra</userName>
</LatestReviewers>
<TradingAccount>
<Core>
<LocalId>0170485038</LocalId>
</Core>
<SystemCodes>
<SystemCodeType>
<Id>TradingAccountGSID</Id>
</SystemCodeType>
<Value>4973662</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
<SystemCodes>
<SystemCodeType>
<Id>NTPA</Id>
</SystemCodeType>
<Value>Y37F40</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
<SystemCodes>
<SystemCodeType>
<Id>FXOPs</Id>
</SystemCodeType>
<Value>L61774</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
<SystemCodes>
<SystemCodeType>
<Id>SDSFB</Id>
</SystemCodeType>
<Value>MARSH38LONGB</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
</TradingAccount>
<Country>
<IsoCode>DE</IsoCode>
</Country>
<Security>
<Id>COB</Id>
</Security>
<SettlementMethod>
<Id>EURO_CLEAR</Id>
</SettlementMethod>
<Currency>
<IsoCode>EUR</IsoCode>
</Currency>
<DefaultSsi>true</DefaultSsi>
<TermsOfDelivery>
<Id>FOP</Id>
</TermsOfDelivery>
<SettlementType>NON_CASH</SettlementType>
<ClassOfAccount>BOTH</ClassOfAccount>
<SettlementChainEntries>
<StepType>NonCashDeagReag</StepType>
<IdentifierType>
<Id>SWIFT_BIC</Id>
</IdentifierType>
</SettlementChainEntries>
<SettlementChainEntries>
<StepType>NonCashDecuRecu</StepType>
<IdentifierType>
<Id>SWIFT_BIC</Id>
</IdentifierType>
</SettlementChainEntries>
<SettlementChainEntries>
<StepType>NonCashPset</StepType>
<Bic>MGTCBEBEECL</Bic>
<AccountNumber>47950</AccountNumber>
<IdentifierType>
<Id>SWIFT_BIC</Id>
</IdentifierType>
</SettlementChainEntries>
<RecDel>BOTH</RecDel>
<CptyFirm>CPTY</CptyFirm>
<CountryOfSettlement/>
<SettleTypeOverride>
<Id>EE</Id>
</SettleTypeOverride>
</StandingSettlementInstruction>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StandingSettlementInstruction xmlns="http://www.service.cdds.cs.com/ssiData_2">
<StableChangeVersion>5</StableChangeVersion>
<Core>
<LocalId>0159515092</LocalId>
<EffectiveDate>2015-04-27T00:00:00.000-04:00</EffectiveDate>
<ClosingDate>2018-07-11T18:00:56.487-04:00</ClosingDate>
<DataStatus>Closed</DataStatus>
<InternalIdentifier>00000000-0000-0000-0000-00000302953a</InternalIdentifier>
</Core>
<Change>
<LastApprovedVersion>5</LastApprovedVersion>
<LatestReviewTime>2018-07-11T18:00:56.487-04:00</LatestReviewTime>
</Change>
<SystemCodes>
<SystemCodeType>
<Id>NTPANY</Id>
</SystemCodeType>
<Value>2YVED0</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
<SystemCodes>
<SystemCodeType>
<Id>NTPA</Id>
</SystemCodeType>
<Value>YXWZS0</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
<LatestReviewers>
<userName>AlertDownloader</userName>
</LatestReviewers>
<TradingAccount>
<Core>
<LocalId>0159514367</LocalId>
</Core>
<SystemCodes>
<SystemCodeType>
<Id>TradingAccountGSID</Id>
</SystemCodeType>
<Value>4770729</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
<SystemCodes>
<SystemCodeType>
<Id>NTPANY</Id>
</SystemCodeType>
<Value>2YVED0</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
<SystemCodes>
<SystemCodeType>
<Id>NTPA</Id>
</SystemCodeType>
<Value>YXWZS0</Value>
<ValueStatus>Active</ValueStatus>
</SystemCodes>
</TradingAccount>
<Country>
<IsoCode>MX</IsoCode>
</Country>
<Security>
<Id>EQU</Id>
</Security>
<SettlementMethod>
<Id>INDEVAL</Id>
</SettlementMethod>
<AlertIndex>1</AlertIndex>
<Currency>
<IsoCode>MXN</IsoCode>
</Currency>
<DefaultSsi>true</DefaultSsi>
<TermsOfDelivery>
<Id>DVP</Id>
</TermsOfDelivery>
<SettlementType>NON_CASH</SettlementType>
<ClassOfAccount>BOTH</ClassOfAccount>
<SettlementChainEntries>
<StepType>NonCashPset</StepType>
<Bic>INDEMXMMXXX</Bic>
<IdentifierType>
<Id>SWIFT_BIC</Id>
</IdentifierType>
</SettlementChainEntries>
<SettlementChainEntries>
<StepType>NonCashDeagReag</StepType>
<SettlementAgentName>CITIBANK, MEXICO</SettlementAgentName>
<Bic>CITIUS33MER</Bic>
<AccountNumber>229347</AccountNumber>
<IdentifierType>
<Id>SWIFT_BIC</Id>
</IdentifierType>
</SettlementChainEntries>
<SettlementChainEntries>
<StepType>NonCashDecuRecu</StepType>
<SettlementAgentName>STATE STREET BANK AND TRUST COMPANY</SettlementAgentName>
<Bic>SBOSUS3CXXX</Bic>
<IdentifierType>
<Id>SWIFT_BIC</Id>
</IdentifierType>
</SettlementChainEntries>
<RecDel>BOTH</RecDel>
<CptyFirm>CPTY</CptyFirm>
</StandingSettlementInstruction>.



I want the data in the XML to output CSV file. like

SystemCodes|LastApprovedVersion|LocalId|EffectiveDate|DataStatus|InternalIdentifier|TradingAccountLocalId|StableChangeVersion,
Y37F40|2|0171375670|2018-06-24T06:38:47.093-04:00|Active|00000000-0000-0000-0000-000008180d98|0170485038|2
Reply
#2
What have you tried? And please read the BBCode link in my signature below before posting your code.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  dictionary output to text file (beginner) Delg_Dankil 2 1,163 Jul-12-2023, 11:45 AM
Last Post: deanhystad
  Output File ? Kessie1971 11 1,963 May-11-2023, 08:31 AM
Last Post: buran
  Can we store value in file if we open file in read mode? prasanthbab1234 3 2,547 Sep-26-2020, 12:10 PM
Last Post: ibreeden
  Read text file, process data and print specific output Happythankyoumoreplease 3 2,902 Feb-20-2020, 12:19 PM
Last Post: jefsummers
  Data extraction from (multiple) MS Word file(s) in python Den0st 8 7,884 Sep-19-2019, 10:07 PM
Last Post: Den0st
  Parse text from a .txt file and save multiple output .txt rattlerskin 10 11,042 Aug-25-2019, 08:50 PM
Last Post: dwirsig
  help! function that checks if a file is a bed file, tips so i can code it myself lilyS 1 2,359 May-31-2019, 12:41 PM
Last Post: ichabod801
  reading text file and writing to an output file precedded by line numbers kannan 7 10,366 Dec-11-2018, 02:19 PM
Last Post: ichabod801
  How to get output in a file? BananaRekt 3 3,109 May-06-2018, 06:04 PM
Last Post: buran
  Unable to output the indices from an input file rainbow2312 1 2,962 Nov-18-2017, 05:53 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020