Sponsored Content
Top Forums Shell Programming and Scripting Map values of blocks in a single line Post 302749723 by rdrtx1 on Saturday 29th of December 2012 05:13:28 AM
Old 12-29-2012
try:
Code:
awk '
BEGIN {
  z="#,NODE";
  s="IMSIS,M,NA,OBA,BO,PLMN,MAPVER,NRRG,CBA,CBAZ,CAMEL,INOPER,OWNMS,NATMS,ERIS,STALL";
  k=split(s,h,","); print z "," s;
}
$1 == "END" && c==0 {
  a[h[1]]=v; a[h[2]]="UNIDENTIFIED";
  printf cn[node] "," node ",";
  for (i=1; i<=k; i++) printf  (i<k) ? a[h[i]]",":a[h[i]]"\n";
  delete a;
}
!$1 && c==1 {
  if (a[h[1]]) {
    printf cn[node] "," node ",";
    for (i=1; i<=k; i++) printf  (i<k) ? a[h[i]]",":a[h[i]]"\n";
  }
  delete a;
}
/<..*;/ {++n; c=0; j=split($0,o,"[:=;!]"); w=o[j-4]; v=o[j-3]; node=o[j-1]; cn[node]++}
!$1 && c==0 {next}
$1 && c==1 {
  if (NF>1) for (i=1; i<=NF-1; i++) a[h[i]]=$i;
  f=v=$NF; x=sub("[-].*","", f); x=sub(".*[-]","", v);
  if (x) {a[f]=v} else {a[f]=1};
}
$1 == w {c=1}
' input2.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find 5 lines and replace with 18 line in sql file where it contains multiple blocks.

My sql file xyz_abc.sql in this file there are multiple sql block in this block I need to find the following block rem Subset Rows (&&tempName.*) CREATE VIEW &&tempName.* AS SELECT * FROM &&tempName.* WHERE f is not null and replace with following code rem Subset Rows... (9 Replies)
Discussion started by: Zaheer.mic
9 Replies

2. Shell Programming and Scripting

how to split this file into blocks and then send these blocks as input to the tool called Yices?

Hello, I have a file like this: FILE.TXT: (define argc :: int) (assert ( > argc 1)) (assert ( = argc 1)) <check> # (define c :: float) (assert ( > c 0)) (assert ( = c 0)) <check> # now, i want to separate each block('#' is the delimeter), make them separate files, and then send them as... (5 Replies)
Discussion started by: paramad
5 Replies

3. Shell Programming and Scripting

How to map the values of an array in perl?

Hi, I have 2 arrays: @names=qw(amith veena chaitra); @files=qw(file.txt file1.txt file3.txt); There is one to one relationship between names and files. There needs to be mapping created between names and files. The output should be like this: amith --> file.txt veena --->... (3 Replies)
Discussion started by: vanitham
3 Replies

4. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

5. Shell Programming and Scripting

Show distinct values of a key from a single line

Hi All, I am newbie to linux. Can somebody help me with following requirement. I have one huge line. I have to find out particular key/value pair to see the distinct value of that key. Portion of the String:- <?xml version="1.1" encoding="UTF-8"?> <Data><Val Ti="1342750845538" Du="0"... (5 Replies)
Discussion started by: kmajumder
5 Replies

6. Shell Programming and Scripting

Row blocks to column blocks

Hello, Searched for a while and found some "line-to-column" script. My case is similar but with multiple fields each row: S02 Length Per S02 7043 3.864 S02 54477 29.89 S02 104841 57.52 S03 Length Per S03 1150 0.835 S03 1321 0.96 S03 ... (9 Replies)
Discussion started by: yifangt
9 Replies

7. Shell Programming and Scripting

sed multiple multi line blocks of text containing pattern

Hi, I have a log file which has sessionids in it, each block in the log starts with a date entry, a block may be a single line or multiple lines. I need to sed (or awk) out the lines/blocks with that start with a date and include the session id. The files are large at several Gb. My... (3 Replies)
Discussion started by: andyatit
3 Replies

8. Shell Programming and Scripting

sed - filter blocks between single delimiters matching a pattern

Hi! I have a file with the following format:CDR ... MSISDN=111 ... CDR ... MSISDN=xxx ... CDR ... MSISDN=xxx ... CDR ... MSISDN=111 (2 Replies)
Discussion started by: Flavius
2 Replies

9. Shell Programming and Scripting

Bring values in the second column into single line (comma sep) for uniq value in the first column

I want to bring values in the second column into single line for uniq value in the first column. My input jvm01, Web 2.0 Feature Pack Library jvm01, IBM WebSphere JAX-RS jvm01, Custom01 Shared Library jvm02, Web 2.0 Feature Pack Library jvm02, IBM WebSphere JAX-RS jvm03, Web 2.0 Feature... (10 Replies)
Discussion started by: kchinnam
10 Replies

10. Solaris

Can I run repair on lot of blocks with single command ?

Hi, I have Solaris-10 OS on T5220. Both local disks were mirrored under SVM. Somehow when one disk gone bad (c0t1d0), other disk (c0t0d0) also got lot of bad block. We have readable data only on c0t0d0, but as soon as server comes after, it hangs when I run few commands because of read errors,... (1 Reply)
Discussion started by: solaris_1977
1 Replies
RDF::Redland::Node(3pm) 				User Contributed Perl Documentation				   RDF::Redland::Node(3pm)

NAME
RDF::Redland::Node - Redland RDF Node (RDF Resource, Property, Literal) Class SYNOPSIS
use RDF::Redland; my $node1=new RDF::Redland::Node("Hello, World!"); my $node2=new RDF::Redland::Node($uri); # $uri is an RDF::Redland::URI my $node3=$node2->clone; my $node4=new RDF::Redland::URINode("http://example.com/"); my $node5=new RDF::Redland::LiteralNode("Hello, World!"); my $node6=new RDF::Redland::XMLLiteral("<tag>content</tag>"); my $node7=new RDF::Redland::BlankNode("genid1"); # alternate more verbose ways: my $node4=RDF::Redland::Node->new_from_uri("http://example.com/"); my $node5=RDF::Redland::Node->new_literal("Hello, World!"); my $node6=RDF::Redland::Node->new_xml_literal("<tag>content</tag>"); my $node7=RDF::Redland::Node->new_from_blank_identifier("genid1"); ... print $node4->uri->as_string," "; # Using RDF::Redland::URI::as_string print $node5->literal_value_as_latin1," "; DESCRIPTION
This class represents RDF URIs, literals and blank nodes in the RDF graph. CONSTRUCTORS
new [STRING | URI | NODE] Create a new URI node, literal node or copy an existing node. If a literal STRING is given, make a plain literal node. If a the argument is of type URI (perl URI or RDF::Redland::URI), make a resource node. Otherwise if the argument is an RDF::Redland::Node NODE, copy it. new_from_uri URI Create a new URI node. URI can be either a RDF::Redland::URI object, a perl URI class or a literal string. An alternative is: new RDF::Redland::URINode("http://example.org/"); new_literal STRING [DATATYPE [XML_LANGUAGE]] Create a new literal node for a literal value STRING. Optional datatype URI DATATYPE (RDF::Redland::URI, perl URI or string) and language (xml:lang attribute) XML_LANGUAGE may also be given. An alternative is: new RDF::Redland::LiteralNode("Hello, World!"); new RDF::Redland::LiteralNode("Bonjour monde!", undef, "fr"); new_xml_literal STRING Create a new XML datatyped literal node for the XML in STRING. An alternative is: new RDF::Redland::XMLLiteral("<tag>content</tag>"); new_from_blank_identifier IDENTIFIER Create a new blank node with blank node identifier IDENTIFIER. An alternative is: new RDF::Redland::BlankNode("id"); clone Copy a RDF::Redland::Node. METHODS
uri Get the current URI of the node as an RDF::Redland::URI object. blank_identifier Get the current blank identifier of the node type Get the node type. It is recommended to use the is_resource, is_literal or is_blank methods in preference to this (both simpler and quicker). The current list of types that are supported are: $RDF::Redland::Node::Type_Resource $RDF::Redland::Node::Type_Literal $RDF::Redland::Node::Type_Blank Example: if ($node->type == $RDF::Redland::Node::Type_Resource) { print "Node is a resource with URI ", $node->uri->as_string, " "; } else { ... } is_resource Return true if node is a resource (with a URI) is_literal Return true if node is a literal is_blank Return true if node is a blank nodeID literal_value Get the node literal value string as UTF-8 (when the node is of type $RDF::Redland::Node::Type_Literal) literal_value_as_latin1 Get the node literal value string converted from UTF-8 to ISO Latin-1 (when the node is of type $RDF::Redland::Node::Type_Literal) literal_value_language Get the node literal XML language (when the node is of type $RDF::Redland::Node::Type_Literal) or undef if not present. literal_value_is_wf_xml Return non 0 if the literal string is well formed XML (when the node is of type $RDF::Redland::Node::Type_Literal). literal_datatype Return the RDF::Redland::URI of the literal datatype or undef if it is not a datatype. as_string Return the RDF::Redland::Node formatted as a string (UTF-8 encoded). equals NODE Return non zero if this node is equal to NODE OLDER METHODS
new_from_literal STRING XML_LANGUAGE IS_WF Create a new RDF::Redland::Node object for a literal value STRING with XML language (xml:lang attribute) XML_LANGUAGE and if content is well formed XML, when IS_WF is non 0. XML_LANGUAGE is optional can can be set to undef. This method remains but using new_literal is prefered. Instead, for plain literals use: $node=new RDF::Redland::Node("blah") new_from_typed_literal STRING [DATATYPE [XML_LANGUAGE]] Renamed to new_literal with same arguments. new_from_uri_string URI_STRING Create a new RDF::Redland::Node object for a resource with URI URI_STRING. It is equivalent to use the shorter: $a=new RDF::Redland::Node->new_from_uri($uri_string) new_from_node NODE Create a new RDF::Redland::Node object from existing RDF::Redland::Node NODE (copy constructor). It is equivalent to use: $new_node=$old_node->clone SEE ALSO
RDF::Redland::Statement AUTHOR
Dave Beckett - http://www.dajobe.org/ perl v5.14.2 2011-05-09 RDF::Redland::Node(3pm)
All times are GMT -4. The time now is 07:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy