Sponsored Content
Top Forums Shell Programming and Scripting Parse XML file into CSV with shell? Post 302263972 by summer_cherry on Tuesday 2nd of December 2008 09:39:00 PM
Old 12-02-2008
hi,

basically use xml parse tools in perl is easy.

Anyway, below boring code can also address the requirement.

You amy try it

Code:
open FH,"<a.txt";
my @arr=<FH>;
close FH;
foreach(@arr){
	while(m/ (.*?=".*?")/){
		my $str=$1;
		$_=$';
		$hash{$1}=$2 if ($str=~m/(.*)="(.*)"/);
	}
	print $hash{issuerName},"|",$hash{symbol},"|",$hash{exch},"|",$hash{curr},"|",$hash{Csymbol},"|",$hash{Cexch},"|",$hash{Ccurr},"\n";
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to parse a XML file using PERL and XML::DOm

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

Parse a string in XML file using shell script

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

regex/shell script to Parse through XML Records

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

Parse XML file in shell script

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

Korn shell program to parse CSV text file and insert values into Oracle database

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

Extract and parse XML data (statistic value) to csv

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

Help to parse csv file with shell script

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

BASH script to parse XML and generate CSV

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

Using shell command need to parse multiple nested tag value of a XML file

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

Pass some data from csv to xml file using shell/python

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
Bio::OntologyIO::InterProParser(3pm)			User Contributed Perl Documentation		      Bio::OntologyIO::InterProParser(3pm)

NAME
Bio::OntologyIO::InterProParser - Parser for InterPro xml files. SYNOPSIS
# don't use this module directly - use Bio::OntologyIO with instead my $ipp = Bio::OntologyIO->new( -format => 'interpro', -file => 't/data/interpro.xml', -ontology_engine => 'simple' ); DESCRIPTION
Use InterProParser to parse InterPro files in xml format. Typical use is the interpro.xml file published by EBI. The xml records should follow the format described in interpro.dtd, although the dtd file is not needed, and the XML file will not be validated against it. FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Peter Dimitrov Email dimitrov@gnf.org APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : Function: Initializes objects needed for parsing. Example : $ipp = Bio::OntologyIO::InterProParser->new( -file => 't/data/interpro.xml', -ontology_engine => 'simple' ) Returns : Object of class Bio::OntologyIO::InterProParser. Args : -file - file name -ontology_engine - type of ontology engine. Should satisfy the OntologyEngine interface requirements. Currently the only option is 'simple'. In the future Graph.pm based engine will be added to the choices. parse Title : parse Usage : Function: Performs the actual parsing. Example : $ipp->parse(); Returns : Args : next_ontology Title : next_ontology Usage : $ipp->next_ontology() Function: Parses the input file and returns the next InterPro ontology available. Usually there will be only one ontology returned from an InterPro XML input. Example : $ipp->next_ontology(); Returns : Returns the ontology as a Bio::Ontology::OntologyEngineI compliant object. Args : See Bio::Ontology::OntologyEngineI. _is_parsed Title : _is_parsed Usage : $obj->_is_parsed($newval) Function: Example : Returns : value of _is_parsed (a scalar) Args : on set, new value (a scalar or undef, optional) secondary_accessions_map Title : secondary_accessions_map Usage : $obj->secondary_accessions_map() Function: This method is merely for convenience, and one should normally use the InterProTerm secondary_ids method to access the secondary accessions. Example : $map = $interpro_parser->secondary_accessions_map; Returns : Reference to a hash that maps InterPro identifier to an array reference of secondary accessions following the InterPro xml schema. Args : Empty hash reference perl v5.14.2 2012-03-02 Bio::OntologyIO::InterProParser(3pm)
All times are GMT -4. The time now is 03:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy