Sponsored Content
Top Forums Shell Programming and Scripting Help converting row data to columns Post 302452018 by durden_tyler on Thursday 9th of September 2010 12:16:19 AM
Old 09-09-2010
Another Perl:

Code:
$ 
$ cat f3
First Name: Gary
Last Name: Larson
DOB: 01/01/2010
POB: US
First Name: Bill
Last Name: Waterson
DOB: 01/01/2009
POB: US
First Name: Scott
Last Name: Adams
DOB: 01/01/2007
POB: US
$ 
$ 
$ perl -ne 'BEGIN {print "First Name  Last Name  DOB  POB\n"}
            /^(First Name:|Last Name:|DOB:|POB:) (.*)$/ && do{print $2," "; $i++}; $i==4 && do{print "\n"; $i=0}' f3
First Name  Last Name  DOB  POB
Gary Larson 01/01/2010 US 
Bill Waterson 01/01/2009 US 
Scott Adams 01/01/2007 US 
$ 
$ 

tyler_durden

Or maybe you want formatted print:

Code:
$ 
$ perl -ne 'BEGIN {printf("%-12s %-12s %-12s %-12s\n","First Name","Last Name","DOB","POB")}
            /^(First Name:|Last Name:|DOB:|POB:) (.*)$/ && do{printf("%-12s ",$2); $i++}; $i==4 && do{print "\n"; $i=0}' f3
First Name   Last Name    DOB          POB         
Gary         Larson       01/01/2010   US           
Bill         Waterson     01/01/2009   US           
Scott        Adams        01/01/2007   US           
$ 
$ 

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting tables of row data into columns of tables

I am trying to transpose tables listed in the format into format. Any help would be greatly appreciated. Input: test_data_1 1 2 90% 4 3 91% 5 4 90% 6 5 90% 9 6 90% test_data_2 3 5 92% 5 4 92% 7 3 93% 9 2 92% 1 1 92% ... Output:... (7 Replies)
Discussion started by: justthisguy
7 Replies

2. Shell Programming and Scripting

How to insert data befor some field in a row of data depending up on values in row

Hi I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example. The original data record should be some thing like this 60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)
Discussion started by: aemunathan
8 Replies

3. Shell Programming and Scripting

How to convert 2 column data into multiple columns based on a keyword in a row??

Hi Friends I have the following input data in 2 columns. SNo 1 I1 Value I2 Value I3 Value SNo 2 I4 Value I5 Value I6 Value I7 Value SNo 3 I8 Value I9 Value ............... ................ SNo N (1 Reply)
Discussion started by: ks_reddy
1 Replies

4. Shell Programming and Scripting

Splitting data from one row as multiple columns

Hi I have a file containing some data as follows: 11-17-2010:13:26 64 4 516414 1392258 11-17-2010:13:26 128 4 586868 695603 11-17-2010:13:26 256 4 474937 1642294 11-17-2010:13:32 64 4 378715 1357066 11-17-2010:13:32 128 4 597981 1684006 ... (17 Replies)
Discussion started by: annazpereira
17 Replies

5. Shell Programming and Scripting

Format row data into columns

I have a file which looks like this: /* ----------------- EDW$MOC139_R_NNA_BR_SUM_FACT2 ----------------- */ insert_job: EDW$MOC139_R_NNA_BR_SUM_FACT2 job_type: c command: /home/btchproc/load_process/batch_files/batch_nna_brn_split_sum_fact2.sh m machine: edwprod02.dsm.pwj.com #owner:... (29 Replies)
Discussion started by: Gangadhar Reddy
29 Replies

6. Shell Programming and Scripting

converting column to row

Hi everyone.. I have a list of values in a file... 1.2345e-1 2.282828e+ 3.2341e-1 1.1223445e-1 I am interested in converting this column to a row.. 1.2345e-1 2.282828e+ 3.2341e-1 1.1223445e-1 can anyone pls help?? I am a liunx newbie.. Thanks.. (7 Replies)
Discussion started by: kjha
7 Replies

7. UNIX for Dummies Questions & Answers

Select 2 columns and transpose row by row

Hi, I have a tab-delimited file as follows: 1 1 2 2 3 3 4 4 a a b b c c d d 5 5 6 6 7 7 8 8 e e f f g g h h 9 9 10 10 11 11 12 12 i i j j k k l l 13 13 14 14 15 15 16 16 m m n n o o p p The output I need is: 1 1 a a 5 5 e e 9 9 i i 13... (5 Replies)
Discussion started by: mvaishnav
5 Replies

8. Emergency UNIX and Linux Support

[Solved] Mysql - Take data from row and copy it to another row

Sorry if I repost my question in this section, but I'm really in a hurry since I have to finish my work... :( Dear community, I have a table with two rows like: Row1 Row2 ======= ======= 7,3 text 1 1,3 text 2 1,2,3 blabla What i need to do is add/copy... (2 Replies)
Discussion started by: Lord Spectre
2 Replies

9. Shell Programming and Scripting

Converting data from specific columns

i have a file (csv or txt or anything which has 4 columns (id,name,number,location) and it contains data. i want to convert the data of specific columns like name to ooooo and number to 88888 matching the field length of that columns. for example if name column has anthony which is 7, it should... (2 Replies)
Discussion started by: prajaktaraut
2 Replies
Prima::FontDialog(3)					User Contributed Perl Documentation				      Prima::FontDialog(3)

NAME
Prima::FontDialog - standard font dialog SYNOPSIS
use Prima::FontDialog; my $f = Prima::FontDialog-> create; return unless $f-> execute == mb::OK; $f = $f-> logFont; print "$_:$f->{$_} " for sort keys %$f; DESCRIPTION
The dialog provides selection of font by name, style, size, and encoding. The font selected is returned by logFont property. API
Properties fixedOnly BOOLEAN Selects whether only the fonts of fixed pitch ( 1 ) or all fonts ( 0 ) are displayed in the selection list. Default value: 0 logFont FONT Provides access to the interactive font selection as a hash reference. FONT format is fully compatible with "Prima::Drawable::font". showHelp BOOLEAN Create-only property. Specifies if the help button is displayed in the dialog. Default value: 0 Events BeginDragFont Called when the user starts dragging a font from the font sample widget by left mouse button. Default action reflects the status in the dialog title EndDragFont $WIDGET Called when the user releases the mouse drag over a Prima widget. Default action applies currently selected font to $WIDGET. AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>. SEE ALSO
Prima, Prima::Window, Prima::Drawable. perl v5.14.2 2009-02-24 Prima::FontDialog(3)
All times are GMT -4. The time now is 07:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy