![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help!!! Shell script to parse data file. | yajaykumar | Shell Programming and Scripting | 3 | 09-24-2008 07:19 AM |
| Unix shell script to parse the contents of comma-separated file | KrishnaSaran | Shell Programming and Scripting | 11 | 06-20-2008 06:43 AM |
| Parse a string in XML file using shell script | ayhanne | Shell Programming and Scripting | 46 | 01-09-2008 12:33 PM |
| How to parse config variables from external file to shell script | pradsh | Shell Programming and Scripting | 2 | 07-09-2007 03:21 PM |
| shell scripts that parse log files | trueman82 | Shell Programming and Scripting | 4 | 11-22-2006 06:09 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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? |
| Bookmarks |
| Tags |
| shell help, shell script, shell scripting, unix scripting, unix scripting basics, xml |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|