Sponsored Content
Full Discussion: Convert XML to CSV format
Top Forums Shell Programming and Scripting Convert XML to CSV format Post 302325224 by kumar04 on Saturday 13th of June 2009 06:49:32 PM
Old 06-13-2009
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.
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Waveset PUBLIC 'waveset.dtd' 'waveset.dtd'>
<Waveset>
<Object name='ra8736'>
  <Attribute name='ADDRESS' value='N'/>
  <Attribute name='AVAILABLE' value='Y'/>
  <Attribute name='DOB' value='19790608'/>
  <Attribute name='DEPARTMENT'>
    <List>
      <String>A</String>
      <String>B</String>
      <String>C</String>
    </List>
  </Attribute>
  <Attribute name='EMAIL' value='Y'/>
  <Attribute name='EXTERNAL' value='ra8736'/>
  <Attribute name='FIRSTNAME' value='Ta'/>
  <Attribute name='LASTNAME' value='Batt'/>
  <Attribute name='PASSWD' value='6378ar'/>
  <Attribute name='PHONE' value='N'/>
  <Attribute name='USERID' value='ra8736'/>
  <Attribute name='password'>
    <EncryptedData>1EBAA6BFE64E7639:5419E216:11B575EA443:-7FFB|3Vny+ukWUEPnat0v7Z+5vA==</EncryptedData>
  </Attribute>
</Object>
<Object name='ug7444'>
  <Attribute name='ADDRESS' value='N'/>
  <Attribute name='AVAILABLE' value='Y'/>
  <Attribute name='DOB' value='19320101'/>
  <Attribute name='DEPARTMENT' value='E'/>
  <Attribute name='EXTERNAL' value='ug7444'/>
  <Attribute name='FIRSTNAME' value='Zel'/>
  <Attribute name='LASTNAME' value='dee'/>
  <Attribute name='PASSWD' value='4447gu'/>
  <Attribute name='USERID' value='ug7444'/>
  <Attribute name='password'>
    <EncryptedData>1EBAA6BFE64E7639:5419E216:11B575EA443:-7FFB|Lq/Ql84BRK651SXD9xk1KA==</EncryptedData>
  </Attribute>
</Object>
<Object name='vb9838'>
  <Attribute name='password'>
    <EncryptedData>1EBAA6BFE64E7639:5419E216:11B575EA443:-7FFB|JFQ3UBXuwAWDUwpSPn+cRw==</EncryptedData>
  </Attribute>
</Object>
</Waveset>

The CSV format of each object from the above XML file should look like the following;

Code:
id|ADDRESS|AVAILABLE|DOB|DEPARTMENT|EMAIL|EXTERNAL|FIRSTNAME|LASTNAME|PASSWD|PHONE|USERID|password
ra8736|N|Y|19790608|A,B,C|Y|ra8736|Ta|Batt|6378ar|N|ra8736|1EBAA6BFE64E7639:5419E216:11B575EA443:-7FFB|3Vny+ukWUEPnat0v7Z+5vA==
ug7444|N|Y|19320101|E||ug7444|Zel|dee|4447gu||ug7444|1EBAA6BFE64E7639:5419E216:11B575EA443:-7FFB|Lq/Ql84BRK651SXD9xk1KA==
vb9838||||||||||||1EBAA6BFE64E7639:5419E216:11B575EA443:-7FFB|JFQ3UBXuwAWDUwpSPn+cRw==

Could you please help me how can I convert XML file to CSV in perl? If you have a perl sample code, that will be a great help.

Thanks for your help in advance.

-Kumar

Last edited by kumar04; 06-16-2009 at 02:19 PM..
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Convert a csv file to an xls format

Hi, I have a file coming in xxx.txt(csv format) i do some work on it and i need to send out as a .xls format. Is there any way there is some code i can use in my script to convert this? I'm struggling on this. Thanks (11 Replies)
Discussion started by: Pablo_beezo
11 Replies

3. Shell Programming and Scripting

convert files into csv format using perl

Hi all perl gurus, I need your help to get the desired output in perl. I have a file which has text in it in the format Connection request start timestamp = 12/08/2008 00:58:36.956700 Connect request completion timestamp = 12/08/2008 00:58:36.959729 Application idle time ... (10 Replies)
Discussion started by: azs0309
10 Replies

4. Shell Programming and Scripting

Help needed to convert delimited to CSV format

I have a file with the data as follows.. FILE 1|#START|Jan 22 15:03 FILE 1|#END|Jan 22 16:06 FILE 2|#START|Jan 22 5:15 FILE 2|#END|Jan 22 5:25 FILE 3|#START|Jan 22 07:03 FILE 3|#END|Jan 22 08:15 FILE 4|#START|Jan 22 16:09 FILE 4|#END|Jan 22 16:55 FILE 1|#START|Jan 22 18:15 FILE... (5 Replies)
Discussion started by: karthikd214
5 Replies

5. Shell Programming and Scripting

Convert the below file to csv format

Hi , i want to change this question, i will post soon.. (6 Replies)
Discussion started by: srikanth2567
6 Replies

6. UNIX for Dummies Questions & Answers

urgent help to convert xml to xsl or csv

Urgent help to transfer data from .xml to xl sheet where each attribute and value goes into seperate column.Please help me with the command.Please help Thanks Uma (9 Replies)
Discussion started by: umapearl
9 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

Convert XML to CSV using awk or shell script

Hello, I am working on a part of code where I need a awk or shell script to convert the given XML file to CSV or TXT file. There are multiple xml files and of different structure, so a single script is required for converting data. I did find a lot of solutions in the forum but... (16 Replies)
Discussion started by: Rashmitha
16 Replies
PORTABASE(1)						      General Commands Manual						      PORTABASE(1)

NAME
portabase - an easy-to-use personal database application SYNOPSIS
portabase [ -h | --help | <file> ] portabase command [ -p password ] [ options ] <fromfile> <tofile> DESCRIPTION
PortaBase (portable database) is a personal database application that is available for many platforms, including Linux, Mac OS X, Windows, and Maemo. PortaBase's features include: - One data table per file - String, Integer, Decimal, Boolean, Note (multi-line text), Date, Time, Calculation, Sequence, Image, and Enum column types - Add, edit, and delete rows of data - Custom data views (subsets of the columns in any order) - Filter the displayed rows using sets of conditions - Sort the rows by any combination of columns, each in ascending or descending order - Optional page navigation buttons, with a custom number of rows per page - Add, delete, rearrange, and rename columns at any time - Specify default values for columns - View summary statistics for columns (total, average, min, max, etc.) - Import data from CSV, XML, and MobileDB files - Export data to CSV and XML files - Command-line format conversions (to and from XML, from MobileDB) - Data file encryption - Unicode support - Pick any available font to use throughout the application COMMANDS
PortaBase uses the following commands to indicate a command-line file conversion: fromxml Create a new PortaBase file from the input XML file. frommobiledb Create a new PortaBase file from the input MobileDB file. fromcsv Add rows to an existing PortaBase file from the input CSV file. toxml Create a new XML file from the input PortaBase file. tocsv Create a new CSV file from the input PortaBase file. If an encrypted PortaBase file is to be read or created, the following option can be used immediately after the command: -p <password> Open or create the encrypted PortaBase file using the given password The toxml and tocsv commands accept the following options: -v <view> Apply the named view before exporting. -s <sorting> Apply the named sorting before exporting. -f <filter> Apply the named filter before exporting. The fromcsv command supports one option: -e <encoding> Specifies the text encoding of the imported CSV file; options are UTF-8 (the default) and Latin-1. OPTIONS
PortaBase accepts the following options: -h, --help Display usage instructions. FILES
$HOME/.qt/portabaserc - user-specific settings. Stores information on font, checkbox editing, delete confirmations, etc. AUTHOR
This manual page was written by Jeremy Bowman <jmbowman@alum.mit.edu>, for the Debian GNU/Linux system (but may be used by others). April 16, 2010 PORTABASE(1)
All times are GMT -4. The time now is 02:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy