11-25-2008
Parse XML file into CSV with shell?
Hi,
It's been a few years since college when I did stuff like this all the time. Can someone help me figure out how to best tackle this problem? I need to parse a file full of entries that look like this:
<eq action="A" sectyType="0" symbol="PGR" exch="CA" curr="VEF" sess="NORM" dfltInd="1" issuerName="PROAGROI-7 B" issuShortDesc="VEB100" sectySubType="" sedol="2705132" isin="VEV000901000" cusip="" localCode="VEV000901000" localId="5" Csymbol="PGR" Cexch="CA" Ccurr="VEF" Csess="NORM" Psymbol="PGR" Pexch="CA" Pcurr="VEF" Psess="NORM" Ssymbol="PGR" Sexch="CA" Scurr="VEF" Ssess="NORM" exclPFInd="0" ranking="" longIssuerName="PROAGRO, C.A." issuLongDesc="VEB100" sicCode="" exchSym="" streetSym="" mostLiquid="0" />
And I want the data in a csv file with the following columns:
issuerName (symbol-exch) | symbol | exch | curr | Csymbol | Cexch | Ccurr
I only want the data that's in each of these fields, so I want PGR, not symbol="PGR"
I can use sed to strip away everything but the data I need -- which I've done -- but the data remains in its original order, not the one I'm looking for: (Note, the issuerName field is in Brackets for visual purposes).
PGR CA VEF [PROAGROI-7 B] PGR CA VEF
What's the best way to re-order the above line according to my CSV needs? Or is there a different approach I should be taking entirely?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to know the way. I have got parsing down some nodes. But I was unable to get the child node perfectly. If you have code please send it. It will be very useful for me. (0 Replies)
Discussion started by: girigopal
0 Replies
2. Shell Programming and Scripting
Hi! I'm just new here and don't know much about shell scripting. I just want to ask for help in creating a shell script that will parse a string or value of the status in the xml file. Please sample xml file below. Can you please help me create a simple script to get the value of status? Also it... (46 Replies)
Discussion started by: ayhanne
46 Replies
3. Shell Programming and Scripting
Hi All,
I have been working on something that doesn't seem to have a clear regex solution and I just wanted to run it by everyone to see if I could get some insight into the method of solving this problem.
I have a flat text file that contains billing records for users, however the records... (5 Replies)
Discussion started by: Jerrad
5 Replies
4. Shell Programming and Scripting
Hi Everybody,
I have an XML file containing some data and i want to extract it, but the specific issue in my file is that the data is repeated some times like the following example :
<section1>
<subsection1>
X=...
Y=...
Z=...
<\subsection1>
<subsection2>
X=...
Y=...
Z=...... (2 Replies)
Discussion started by: yassine
2 Replies
5. Shell Programming and Scripting
Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database.
I need to write the korn shell program on Red Hat Enterprise Linux server.
Oracle database is 10g. (15 Replies)
Discussion started by: shellguy
15 Replies
6. Shell Programming and Scripting
Hi All,
I need to parse some statistic data from the "measInfo" -eg. 25250000 (as highlighted) and return the result into line by line, and erasing all other unnecessary info/tag.
Thought of starting with grep "measInfoID="25250000" but this only returns 1 line. How do I get all the output... (8 Replies)
Discussion started by: jackma
8 Replies
7. UNIX for Dummies Questions & Answers
Hello !
I am very aware that this is not the first time this question is asked here, because I have already read a lot of previous answers, but none of them worked, so...
As said in the title, I want to read a csv file with a bash script.
Here is a sample of the file:
... (4 Replies)
Discussion started by: Grhyll
4 Replies
8. Shell Programming and Scripting
Hi All,
Hope all you are doing good! Need your help. I have an XML file which needs to be converted CSV file. I am not an expert of awk/sed so your help is highly appreciated!!
XML file looks like this:
<l:event dateTime="2013-03-13 07:15:54.713" layerName="OSB" processName="ABC"... (2 Replies)
Discussion started by: bhaskar_m
2 Replies
9. Shell Programming and Scripting
I have this XML file -
<gp>
<mms>1110012</mms>
<tg>988</tg>
<mm>LongTime</mm>
<lv>
<lkid>StartEle=ONE, Desti = Motion</lkid>
<kk>12</kk>
</lv>
<lv>
<lkid>StartEle=ONE, Source = Velocity</lkid>
<kk>2</kk>
</lv>
<lv>
... (3 Replies)
Discussion started by: NeedASolution
3 Replies
10. Shell Programming and Scripting
Hello gurus,
I have a csv file with bunch of datas in each column. (see attached)
Now I have an .xml file in the structure of below:
?xml version="1.0" ?>
<component id="root" name="root">
<component id="system" name="system">
<param name="number_of_A" value="8"/>
... (5 Replies)
Discussion started by: Zam_1234
5 Replies
LEARN ABOUT FREEBSD
kvm_nlist
KVM_NLIST(3) BSD Library Functions Manual KVM_NLIST(3)
NAME
kvm_nlist -- retrieve symbol table names from a kernel image
LIBRARY
Kernel Data Access Library (libkvm, -lkvm)
SYNOPSIS
#include <kvm.h>
#include <nlist.h>
int
kvm_nlist(kvm_t *kd, struct nlist *nl);
DESCRIPTION
The kvm_nlist() function retrieves the symbol table entries indicated by the name list argument nl. This argument points to an array of
nlist structures, terminated by an entry whose n_name field is NULL (see nlist(3)). Each symbol is looked up using the n_name field, and if
found, the corresponding n_type and n_value fields are filled in. These fields are set to 0 if the symbol is not found.
The kldsym(2) system call is used to locate the symbol. This is a less than perfect emulation of the nlist values but has the advantage of
being aware of kernel modules and is reasonably fast.
RETURN VALUES
The kvm_nlist() function returns the number of invalid entries found. If the kernel symbol table was unreadable, -1 is returned.
SEE ALSO
kldsym(2), kvm(3), kvm_close(3), kvm_getargv(3), kvm_getenvv(3), kvm_geterr(3), kvm_getprocs(3), kvm_open(3), kvm_openfiles(3), kvm_read(3),
kvm_write(3)
BSD
June 4, 1993 BSD