Sponsored Content
Full Discussion: How to convert xml to csv ?
Top Forums Shell Programming and Scripting How to convert xml to csv ? Post 302925320 by bartus11 on Sunday 16th of November 2014 06:07:51 AM
Old 11-16-2014
When you run your code it says pretty clearly why it can't print the details for the second child node:
Code:
Not a HASH reference at ...

Now, modify your code to print the contents of $FreemanFees using Data:Smilieumper at the beginning of each loop run, then compare the output for the first child node and the second child node. Do you see the difference? (TIP: look at the line containing "ManagerFeeAndCredit" key).

PS: "use strict;" should always be enabled.
 

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

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

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

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

7. Shell Programming and Scripting

convert huge .xml file in .csv with specific column.

I have huge xml file in server and i want to convert it to .csv with specific column ... i have search in blog but i didn't get any usefully command. Thanks in advance (1 Reply)
Discussion started by: pareshkp
1 Replies

8. Shell Programming and Scripting

Convert XML file to CSV file

Hi Guys, I am new to Shell scripting and need to convert an XML files to a CSV file. My actual problem is that XML file loading is taking hours and I have decided to convert the XML structure to row based data in a CSV file. My XML file: Message846 can repeat within main loop and... (1 Reply)
Discussion started by: qamar.shahbaz
1 Replies

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

10. UNIX for Advanced & Expert Users

Convert CSV file to nested XML file using UNIX/PERL?

we have a CSV which i need to convert to XML using Perl or Unix shell scripting. I was able to build this XML in oracle database. However, SQL/XML query is running for long time. Hence, I'm considering to write a Perl or shell script to generate this XML file. Basically need to build this XML... (3 Replies)
Discussion started by: laknar
3 Replies
tree(n) 							Tcl Data Structures							   tree(n)

NAME
tree - Create and manipulate tree objects SYNOPSIS
package require Tcl 8.2 package require struct ?1.2.1? treeName option ?arg arg ...? treeName append node ?-key key? value treeName children node treeName cut node treeName delete node ?node ...? treeName depth node treeName destroy treeName exists node treeName get node ?-key key? treeName getall node treeName keys node treeName keyexists node ?-key key? treeName index node treeName insert parent index ?child ?child ...?? treeName isleaf node treeName lappend node ?-key key? value treeName move parent index node ?node ...? treeName next node treeName numchildren node treeName parent node treeName previous node treeName set node ?-key key? ?value? treeName size ?node? treeName splice parent from ?to? ?child? treeName swap node1 node2 treeName unset node ?-key key? treeName walk node ?-order order? ?-type type? -command cmd DESCRIPTION
The ::struct::tree command creates a new tree object with an associated global Tcl command whose name is treeName. This command may be used to invoke various operations on the tree. It has the following general form: treeName option ?arg arg ...? Option and the args determine the exact behavior of the command. A tree is a collection of elements, called nodes, one of which is distinguished as a root, along with a relation ("parenthood") that places a hierarchical structure on the nodes. (Data Structures and Algorithms; Aho, Hopcroft and Ullman; Addison-Wesley, 1987). In addition to maintaining the node relationships, this tree implementation allows any number of keyed values to be associated with each node. The following commands are possible for tree objects: treeName append node ?-key key? value Appends a value to one of the keyed values associated with an node. If no key is specified, the key data is assumed. treeName children node Return a list of the children of node. treeName cut node Removes the node specified by node from the tree, but not its children. The children of node are made children of the parent of the node, at the index at which node was located. treeName delete node ?node ...? Remove the specified nodes from the tree. All of the nodes' children will be removed as well to prevent orphaned nodes. treeName depth node Return the number of steps from node node to the root node. treeName destroy Destroy the tree, including its storage space and associated command. treeName exists node Remove true if the specified node exists in the tree. treeName get node ?-key key? Return the value associated with the key key for the node node. If no key is specified, the key data is assumed. treeName getall node Returns a serialized list of key/value pairs (suitable for use with [array set]) for the node. treeName keys node Returns a list of keys for the node. treeName keyexists node ?-key key? Return true if the specified key exists for the node. If no key is specified, the key data is assumed. treeName index node Returns the index of node in its parent's list of children. For example, if a node has nodeFoo, nodeBar, and nodeBaz as children, in that order, the index of nodeBar is 1. treeName insert parent index ?child ?child ...?? Insert one or more nodes into the tree as children of the node parent. The nodes will be added in the order they are given. If par- ent is root, it refers to the root of the tree. The new nodes will be added to the parent node's child list at the index given by index. The index can be end in which case the new nodes will be added after the current last child. If any of the specified children already exist in treeName, those nodes will be moved from their original location to the new loca- tion indicated by this command. If no child is specified, a single node will be added, and a name will be generated for the new node. The generated name is of the form nodex, where x is a number. If names are specified they must neither contain whitespace nor colons (":"). The return result from this command is a list of nodes added. treeName isleaf node Returns true if node is a leaf of the tree (if node has no children), false otherwise. treeName lappend node ?-key key? value Appends a value (as a list) to one of the keyed values associated with an node. If no key is specified, the key data is assumed. treeName move parent index node ?node ...? Make the specified nodes children of parent, inserting them into the parent's child list at the index given by index. treeName next node Return the right sibling of node, or the empty string if node was the last child of its parent. treeName numchildren node Return the number of immediate children of node. treeName parent node Return the parent of node. treeName previous node Return the left sibling of node, or the empty string if node was the first child of its parent. treeName set node ?-key key? ?value? Set or get one of the keyed values associated with a node. If no key is specified, the key data is assumed. Each node that is added to a tree has the value "" assigned to the key data automatically. A node may have any number of keyed values associated with it. If value is not specified, this command returns the current value assigned to the key; if value is specified, this command assigns that value to the key. treeName size ?node? Return a count of the number of descendants of the node node; if no node is specified, root is assumed. treeName splice parent from ?to? ?child? Insert a node named child into the tree as a child of the node parent. If parent is root, it refers to the root of the tree. The new node will be added to the parent node's child list at the index given by from. The children of parent which are in the range of the indices from and to are made children of child. If the value of to is not specified it defaults to end. If no name is given for child, a name will be generated for the new node. The generated name is of the form nodex, where x is a number. The return result from this command is the name of the new node. treeName swap node1 node2 Swap the position of node1 and node2 in the tree. treeName unset node ?-key key? Remove a keyed value from the node node. If no key is specified, the key data is assumed. treeName walk node ?-order order? ?-type type? -command cmd Perform a breadth-first or depth-first walk of the tree starting at the node node. The type of walk, breadth-first or depth-first, is determined by the value of type; bfs indicates breadth-first, dfs indicates depth-first. Depth-first is the default. The order of the walk, pre-, post-, both- or in-order is determined by the value of order; pre indicates pre-order, post indicates post-order, both indicates both-order and in indicates in-order. Pre-order is the default. Pre-order walking means that a parent node is visited before any of its children. For example, a breadth-first search starting from the root will visit the root, followed by all of the root's children, followed by all of the root's grandchildren. Post-order walk- ing means that a parent node is visited after any of its children. Both-order walking means that a parent node is visited before and after any of its children. In-order walking means that a parent node is visited after its first child and before the second. This is a generalization of in-order walking for binary trees and will do the right thing if a binary is walked. The combination of a breadth-first walk with in-order is illegal. As the walk progresses, the command cmd will be evaluated at each node. Percent substitution will be performed on cmd before evalu- ation, just as in a bind script. The following substitutions are recognized: %% Insert the literal % character. %t Name of the tree object. %n Name of the current node. %a Name of the action occurring; one of enter, leave, or visit. enter actions occur during pre-order walks; leave actions occur during post-order walks; visit actions occur during in-order walks. In a both-order walk, the command will be evaluated twice for each node; the action is enter for the first evaluation, and leave for the second. KEYWORDS
tree struct 1.2.1 tree(n)
All times are GMT -4. The time now is 08:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy