Sponsored Content
Top Forums Shell Programming and Scripting Convert XML to CSV using awk or shell script Post 302931206 by Rashmitha on Monday 12th of January 2015 12:18:14 AM
Old 01-12-2015
Thanks for the reply.

Here is the Sample data:
Code:
<Orders>
<Partner>TTTT</Partner>
<Order>
<OrderType>test</OrderType>
<OrderNumber>1000000000</OrderNumber>
<OrderSource/>
<OrderDate>11/14/2014 12:00:00 AM</OrderDate>
..
..
..
..
<BillingAddress>
<Line1>XXXX</Line1>
<Line2/>
<City>stsss</City>
<State>gg</State>
<PostalCode>101010</PostalCode>
<CountryCode>aaaaa</CountryCode>
<Name>mmmmmm</Name>
</BillingAddress>
<ShippingAddress>
<NumberOfItems>3</NumberOfItems>
<Name>mmmmm</Name>
<Line1>abcd</Line1>
<Line2/>
<City>xyz</City>
<State>sjsdjhi</State>
<PostalCode>101010</PostalCode>
<CountryCode>kkkkkk</CountryCode>
<Method>test</Method>
<tag>False</tag>
</ShippingAddress>
<ShippingAddress>
<NumberOfItems>1</NumberOfItems>
<Name>mmmmm</Name>
<Line1>abcd</Line1>
<Line2/>
<City>xyz</City>
<State>sjsdjhi</State>
<PostalCode>101010</PostalCode>
<CountryCode>kkkkkk</CountryCode>
<Method>test</Method>
<tag>False</tag>
</ShippingAddress>
<Item>
<Name>Item1</Name>
<Quantity>3</Quantity>
<UnitPrice>15.99</UnitPrice>
<Eligible>False</Eligible>
<OrderStatus>test</OrderStatus>
<SKU>5-100000</SKU>
</Item
<Item>
<Name>Item2</Name>
<Quantity>1</Quantity>
<UnitPrice>10.49</UnitPrice>
<Eligible>True</Eligible>
<OrderStatus>test</OrderStatus>
<SKU>5-100001</SKU>
</Item>
</Order>
<Order>
..
</Order>
</Orders>

In the Output I need all the tags as Columns. The output file can be CSV or txt file. With the current script, single close tags are not parsed.

Regards,
Rashmitha

Last edited by Corona688; 01-12-2015 at 11:25 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sample Unix script file to convert .xml to .csv

Dear all, Can you send me a script file the changes .xml to .csv file. Thanks, Srinivasa (4 Replies)
Discussion started by: srinivasaphani
4 Replies

2. Shell Programming and Scripting

Help to convert XML to CSV

Apologies if this has already been covered in this site somewhere, I did try looking but without any success. I am new to the whole XML thing, very late starter, and have a requirement to convert an XML fiule to a CSV fomat. I am crrently working on a Solaris OS. Does anyone have any suggestions,... (2 Replies)
Discussion started by: rossingi_33
2 Replies

3. Shell Programming and Scripting

convert this into csv using awk/shell script

Hi Scripting gurus, I need to convert following text snippet into csv. please help Input heading1 = data1 heading2 = data2 .. .. heading n = data n heading 1 = data1 .. .. Output data1,data2,....,data n (3 Replies)
Discussion started by: azs0309
3 Replies

4. Shell Programming and Scripting

Convert XML to CSV format

Can any one give the idea on this, please. I have the following XML file and wants to convert into CSV(comma separated value) format. <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE Waveset PUBLIC 'waveset.dtd' 'waveset.dtd'> <Waveset> <Object name='ra8736'> <Attribute name='ADDRESS'... (2 Replies)
Discussion started by: kumar04
2 Replies

5. Shell Programming and Scripting

Awk script to convert csv to html

Hi Written some script to convert csv to html but could not add table headers.Below are the errors iam getting ./csv2html | more + awk -v border=1 -v width=10 -v bgcolor=black -v fgcolor=white BEGIN { printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\"... (2 Replies)
Discussion started by: zeebala1981
2 Replies

6. Shell Programming and Scripting

Convert XML to Data File in Shell Script

Hi All, I will be getting a huge XML file with a lot of records in it. I need to convert it into multiple data files. SAMPLE XML FILE <ABSProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <ProductSalesHierachy> - <Portfolios> - <Portfolio productCode="P1"> ... (8 Replies)
Discussion started by: ragha81
8 Replies

7. Shell Programming and Scripting

awk convert xml to csv

Hi, I have an xml file and I want to convert it with awk in to a csv file Test.xml <Worksheet ss:Name="Map1"> <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="2" x:FullColumns="1" x:FullRows="1" ss:DefaultColumnWidth="60"> <Row> <Cell><Data... (6 Replies)
Discussion started by: research3
6 Replies

8. Shell Programming and Scripting

Convert xml to csv

I need to convert below xml code to csv. I searched other posts as well but this post (_https://www.unix.com/shell-programming-scripting/174417-extract-parse-xml-data-statistic-value-csv.html) gives "sed command garbled" error. As of now I have written a long script to do it, but can it be done with... (7 Replies)
Discussion started by: dineshydv
7 Replies

9. Shell Programming and Scripting

How to convert xml to csv ?

I am in need of converting billions of XML into csv file to load data to DB, i have found the below code in perl but not sure why it's not working properly. CODE: #!/usr/bin/perl # Script to illustrate how to parse a simple XML file # and pick out all the values for a specific element, in... (1 Reply)
Discussion started by: rspwilliam
1 Replies

10. Shell Programming and Scripting

Covert xml to csv using xsltproc in shell script

Hi, I am not familiar with shell scripting. Please help to convert xml files to csv files using xsltproc command in bash script. Find the xml sample <?xml version="1.0"?> -<Source xmlns="link"> <CompanyCd>DSP</CompanyCd> <SrcSysCd>DSPS</SrcSysCd> <CountryCd>45</CountryCd> ... (2 Replies)
Discussion started by: mathina
2 Replies
ECACCESS-FILE-RMDIR(1p) 				User Contributed Perl Documentation				   ECACCESS-FILE-RMDIR(1p)

NAME
ecaccess-file-rmdir - Remove a Directory on the ECaccess File System SYNOPSIS
ecaccess-file-rmdir -version|-help|-manual ecaccess-file-rmdir [-debug] ecaccess-file DESCRIPTION
Allow removing the Directory ecaccess-file on the ECaccess File System. The ecaccess-file is in the form [domain:][/user-id/]path. Please read the "Shell commands -> File Management" section of the "ecaccess" guide for more information on the ECaccess File System. ARGUMENTS
ecaccess-file Then name of the ECaccess Directory to remove. OPTIONS
-version Display version number and exits. -help Print a brief help message and exits. -manual Prints the manual page and exits. -debug Display the SOAP messages exchanged. EXAMPLES
ecaccess-file-rmdir c1a:/c1a/tmp/systems/xyz/test-dir Remove the test-dir Directory in the "/c1a/tmp/systems/xyz" directory on c1a. SEE ALSO
ecaccess-file-delete, ecaccess-file-get, ecaccess-file-mget, ecaccess-file-modtime, ecaccess-file-mput, ecaccess-file-chmod, ecaccess-file- copy, ecaccess-file-dir, ecaccess-file-mdelete, ecaccess-file-mkdir, ecaccess-file-move, ecaccess-file-put, ecaccess-file-size and ecaccess. perl v5.14.2 2012-04-16 ECACCESS-FILE-RMDIR(1p)
All times are GMT -4. The time now is 04:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy