Sponsored Content
Full Discussion: Simplified file conversion
Top Forums Shell Programming and Scripting Simplified file conversion Post 303017396 by manas_ranjan on Tuesday 15th of May 2018 09:42:35 AM
Old 05-15-2018
Simplified file conversion

Hi All,

I have a file like below
Code:
Topic:price   PartitionCount:5       ReplicationFactor:3     Configs:
        Topic: price  Partition: 0    Leader: 13      Replicas: 13,15,11      Isr: 11,13
        Topic: price  Partition: 1    Leader: 14      Replicas: 14,11,12      Isr: 11,12,14
        Topic: price  Partition: 2    Leader: 12      Replicas: 15,12,13      Isr: 12,13
        Topic: price  Partition: 3    Leader: 11      Replicas: 11,13,14      Isr: 11,14,13
        Topic: price  Partition: 4    Leader: 12      Replicas: 12,14,15      Isr: 12,14

I would like to convert this file into below
Code:
Topic, Partition, Replica Count, ISR Count(In-sync Replica Count)

ln-short the o/p file should look like below
Code:
Price, 0, 3, 2
price, 1, 3, 3
price, 2, 3, 2
price, 3, 3, 3
price, 4, 3, 2

Can anyone help me out?
 

10 More Discussions You Might Find Interesting

1. Solaris

COnversion utility xhtml file to Postscript file

Hi, Can any suggest me some utility to convert xhtml file to postscript file format? Also tell me from where to down load such utility.. With Regards, Dattatray (0 Replies)
Discussion started by: dattatray.b
0 Replies

2. Linux

Simplified find command to find multiple file types

Hi, I'm using the following command to find the multiple requierd file types and its working fine find . -name "*.pl" -o -name "*.pm" -o -name "*.sql" -o -name "*.so" -o -name "*.sh" -o -name "*.java" -o -name "*.class" -o -name "*.jar" -o -name "*.gz" -o -name "*.Z" -type f Though... (2 Replies)
Discussion started by: vickramshetty
2 Replies

3. Shell Programming and Scripting

shell or perl script needed for ldif file to text file conversion

This is the ldf file dn: sdcsmsisdn=1000000049,sdcsDatabase=subscriberCache,dc=example,dc=com objectClass: sdcsSubscriber objectClass: top postalCode: 29600 sdcsServiceLevel: 10 sdcsCustomerType: 14 givenName: Adelia sdcsBlackListAll: FALSE sdcsOwnerType: T-Mobile sn: Actionteam... (1 Reply)
Discussion started by: LinuxFriend
1 Replies

4. Shell Programming and Scripting

Conversion of below Tabs Tex file into CSV format file : shell script needed

Request if some one could provide me shell script that converts the below "input file" to "CSV format file" given Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- ----- ---------------------------------... (7 Replies)
Discussion started by: sreenath1037
7 Replies

5. Shell Programming and Scripting

Conversion of spaces Text file into CSV format file

Input file (each line is separaed by spaces )given below: Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- -----... (18 Replies)
Discussion started by: sreenath1037
18 Replies

6. Linux

File conversion and removing special characters from a file in Linux

I have a .CSV file when I check for the special characters in the file using the command cat -vet filename.csv, i get very lengthy lines with "^@", "^I^@" and "^@^M" characters in between each alphabet in all of the records. Using the code below file filename.csv I get the output as I have a... (2 Replies)
Discussion started by: dhruuv369
2 Replies

7. Shell Programming and Scripting

Simplified awk script for if else statements

Hi, The below awk script that i did is working fine. It gives me the results that i want. But, the script is not smart and very long as i have 8 conditions to meet. The sample script below only show 2 conditions. awk 'BEGIN{FS=OFS=" ~ |\t"} {if (($7>$9) && ($6>$8)){ Ql= $7-$6; Sl=... (6 Replies)
Discussion started by: redse171
6 Replies

8. What is on Your Mind?

New Simplified Log Out for UNIX.COM

Hi, I changed the logout code to just simply log out and go back to the page you were viewing: Was (ending code): eval(standard_error(fetch_error('cookieclear', create_full_url($vbulletin->url), $vbulletin->options, $vbulletin->session->vars), '', false)); Now: $goto = "Location:... (0 Replies)
Discussion started by: Neo
0 Replies

9. What is on Your Mind?

Simplified Registration Page with nCaptcha

At Ravinder's request, I have simplified the new member registration page on both mobile and desktop: Mobile: https://www.unix.com/members/1-albums214-picture909.jpeg Desktop (big image): https://www.unix.com/members/1-albums215-picture907.png (2 Replies)
Discussion started by: Neo
2 Replies

10. UNIX for Beginners Questions & Answers

Simplified Code? Acceptable?

Hi Folks - I have the following peice of code that I believe is uncecesarily long and I modified it to shorten it up. I was hoping one could comment and confirm my approach was acceptable? Original: if then pushd "${_INTRAPATH}" #Search for lines in... (1 Reply)
Discussion started by: SIMMS7400
1 Replies
TM::DM(3pm)						User Contributed Perl Documentation					       TM::DM(3pm)

NAME
TM::DM - Topic Maps, read-only TMDM layer SYNOPSIS
# somehow acquire a map (see TM and its subclasses) my $tm = .... # put a TMDM layer on top of it use TM::DM; my $tmdm = new TM::DM (map => $tm); # get the TMDM topic map item my $topicmap = $tmdm->topicmap; # ask for all topics my @topics = $topicmap->topics; # for all associations my @assocs = $topicmap->associations; # get a particular topic my $adam = $topicmap->topic ('adam'); # get some of its properties $adam->id; $adam->subjectLocators; $adam->subjectIdentifiers; $adam->parent; my @ns = $adam->names; my @os = $adam->occurrences; # similar for assocs my @as = $topicmap->associations (iplayer => 'adam'); $as[0]->type; $as[0]->parent; my @rs = $as[0]->roles; ABSTRACT
This package provides a TMDM-ish (read-only) view on an existing topic map. DESCRIPTION
TMDM, the Topic Maps Data Model http://www.isotopicmaps.org/sam/sam-model/ is the ISO standard for the high-level model for Topic Maps. TMDM Concepts TMDM's main concepts are the topic map item containing any number of topic and association items topic item containing any number of names, occurrence items, subject locators and subject identifiers association item containing a type, a scope and any number of role items name item containing a string, a type and a scope occurrence item containing a data value (together with its data type), a type and a scope role item containing a type and a player All items have an item id and all (except the map) have a parent which links back to where the item belongs. This package implements for each of the above a class and access methods to retrieve actual structure and values from an existing map. Nota bene, there are some deviations from TMDM: o only ONE identifier per item is supported o at most ONE subject locator per topic is supported o no variants are supported (might be added at some stage, poke me) o a scope consists only of a single topic o role items do not have an identity, so they also cannot be reified Modus Operandi Before you can use the TMDM layer, you need TM information in the form of a TM object. Any subclass should do, materialized and non- materialized maps should both be fine. Only with such a map you can instantiate a TMDM layer: use TM::Materialized::AsTMa; my $tm = new TM::Materialized::AsTMa (file => 'test.atm'); use TM::DM; my $tmdm = new TM::DM (map => $tm); Probably the first thing you need to do is to get a handle on the whole topic map: my $topicmap = $tmdm->topicmap; That is delivered as an instance of TM::DM::TopicMap as described below. From there you start to extract topics and associations and that way you then further drill down. Implementation Notes This implementation only supports reading map information, not changing it or modifying the structure of the map. Not that it is impossible to do, but many applications get their map content from elsewhere and a read/write interface is an overkill in these cases. All objects generated here are ephemeral, i.e. they are only instantiated because you wanted the map information embedded into them. This implies that if you ask for one and the same topic twice, you are getting two copies of the topic information. The following will not work as expected: my $t0 = $topicmap->topic ('adam'); my $t1 = $topicmap->topic ('adam'); warn "have the same topic!" if $t0 == $t1; This will work: warn "have the same topic!" if $t0->id eq $t1->id; INTERFACES
TM::DM The TM::DM class itself does not offer much functionality itself. It only keeps the connection to the background map. Constructor The constructor expects exactly one parameter, namely the background map. $tmdm = new TM::DM (map => $tm) Methods topicmap $topicmap = $tmdm->topicmap This method generates a Topic Map item. See TM::DM::TopicMap . TM::DM::TopicMap This class provides access to all TMDM properties: id This returns the item identifier. topics @topics = $topicmap->topics (@list-of-ids) @topics = $topicmap->topics @topics = $topicmap->topics ($selection-spec) This method expects a list containing topic valid identifiers and returns for each of the topics a "TM::DM::Topic" reference. If any of the input identifiers do not denote a valid topic in the map, undef will be returned in its place. If the parameter list is empty, all topics will be returned. Have fun, I mean, use with care. Examples: # round tripping topic ids print map { $_->id } $topicmap->topics ('abel', 'cain' ); print "he again" if $topicmap->topics ('god'); If a selection is specified then the same language as in TM (method "toplets") can be used. associations @as = $topicmap->associations @as = $topicmap->associations (%search_spec); This method retrieves the list of ALL associations when it is invoked without a search specification. See TM for that. reifier This returns the topic item which reifies the association. "undef" is returned if there is none. topic This returns a topic item with that id. This method will die if the id is invalid. Note that always new copies are made. TM::DM::Topic subjectLocators Returns the (only) subject locator (URI string) in the topic item or "undef" if there is none. subjectIdentifiers Returns a list of URI strings. Might be empty. id Returns the item id. parent Returns a TM::DM::TopicMap item in which this topic is embedded. names @names = $topic->names Returns a list of TMDM name items. occurrences @occurrences = $topic->occurrences Returns a list of TMDM occurrences items. roles @roles = $topic->roles Returns a list of TM::DM::Role items where this topic plays any role. TM::DM::Association id Returns the item id. type Returns a TM::DM::Topic item which is the type of the association. This is always defined. scope Returns the scope of the association in the form of a single TM::DM::Topic item. This is always defined as for the unconstrained scope the topic "us" is used (see TM::PSI). roles @roles = $assoc->roles Returns a list of roles of the association. Each role is a TM::DM::Role item. parent Returns a TM::DM::TopicMap item for the embedding map. reifier Returns a TM::DM::Topic item if this association is reified. "undef" otherwise. TM::DM::Occurrence id Returns the item id. value Returns the value (together with the data type) in the form of a TM::Literal object. type Returns a TM::DM::Topic item which is the type of the occurrence. This is always defined. scope Returns the scope of the occurrence in the form of a single TM::DM::Topic item. This is always defined. reifier Returns a TM::DM::Topic item if this occurrence is reified. "undef" otherwise. parent Returns the TM::DM::Topic item of the topic where this occurrence is part of. TM::DM::Name id Returns the item id. value Returns the string value of the name. type Returns a TM::DM::Topic item which is the type of the name. This is always defined. scope Returns the scope of the name in the form of a single TM::DM::Topic item. This is always defined. reifier Returns a TM::DM::Topic item if this name is reified. "undef" otherwise. parent Returns the TM::DM::Topic item of the topic where this name is part of. TM::DM::Role player Returns a TM::DM::Topic item for the topic which is the player in this role. type Returns a TM::DM::Topic item for the topic which is the type of this role. parent Returns a TM::DM::Association item of the association where this role is in. SEE ALSO
TM, TM::Easy COPYRIGHT AND LICENSE
Copyright 200[68] by Robert Barta, <drrho@cpan.org> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2008-05-07 TM::DM(3pm)
All times are GMT -4. The time now is 04:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy