Sponsored Content
Top Forums Shell Programming and Scripting Transpose Data form Different form Post 302717257 by spacebar on Wednesday 17th of October 2012 10:10:21 PM
Old 10-17-2012
The below code should work with data like in your example:
Code:
$ cat A.txt
RL03    RL03_A_1        RL03_B_1        RL03_C_1
RL03    -119.8  -119.5  -119.5
RL07    RL07_A_1        RL07_B_1        RL07_C_1
RL07    -119.3  -119.5  -119.5
RL15    RL15_A_1        RL15_C_1
RL15    -120.5  -119.4
RL16    RL16_A_1        RL16_B_1
RL16    -119.4  -119.1

$ perl -ane 'BEGIN{$lc=0;} if ($lc==0) {@r=@F;$lc++;} else {for $i (1 .. $#r) {print "$F[0]\t$r[$i]\t$F[$i]\n";}$lc=0;@r=();}' A.txt
RL03    RL03_A_1        -119.8
RL03    RL03_B_1        -119.5
RL03    RL03_C_1        -119.5
RL07    RL07_A_1        -119.3
RL07    RL07_B_1        -119.5
RL07    RL07_C_1        -119.5
RL15    RL15_A_1        -120.5
RL15    RL15_C_1        -119.4
RL16    RL16_A_1        -119.4
RL16    RL16_B_1        -119.1

This User Gave Thanks to spacebar For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Changing Unix form to Microsoft Word form to be able to email it to someone.

Please someone I need information on how to change a Unix form/document into a microsoft word document in order to be emailed to another company. Please help ASAP. Thankyou :confused: (8 Replies)
Discussion started by: Cheraunm
8 Replies

2. UNIX for Dummies Questions & Answers

data form

I am user Of linux 9.0 Operating System and I had data form unix Operating system and I am not abel to open it in linux 9.0 Please tell me how can i use unix data in linux . (3 Replies)
Discussion started by: harsh_guru
3 Replies

3. UNIX for Dummies Questions & Answers

changing data into matrix form

Hi, I have a file whose structure is like this 7 7 1 2 3 4 5 1 3 4 8 6 1 4 5 6 0 2 6 8 3 8 2 5 7 8 0 5 7 9 4 1 3 8 0 2 2 3 5 6 8 basically first two row tell the number of rows and column but the data following them are not arranged in that format. now i want to create another... (1 Reply)
Discussion started by: g0600014
1 Replies

4. Shell Programming and Scripting

convert one form of xml data to other

I would like to convert one form of xml tag data to another <DescriptionList> <DescriptionExt language="en" shortDesc="ITALIAN SAUSAGE SUB" longDesc="" sizeDesc="" smallImage="Pictures\sub-italian-sausage.png" largeImage="" forceImageUpdate="yes" /> ... (1 Reply)
Discussion started by: saisus
1 Replies

5. UNIX and Linux Applications

Get the data in my required form using gawk

i had the data in the following form: Branch : 3379 As On : 31-JAN-2009 Page : 1 User Id : OPER1 Date & Time : 01-FEB-2009 04:02:37 ... (2 Replies)
Discussion started by: KANNI786
2 Replies

6. Shell Programming and Scripting

Reformatting data in matrix form

Hi, Some assistance with respect to the following problem will be very helpful. I want to reformat my dataset in the following manner for subsequent analysis. I have first column values (which repeat for each value of 2nd column) which are names, the second column specifies position ad the... (1 Reply)
Discussion started by: newbie83
1 Replies

7. UNIX for Dummies Questions & Answers

Put data in tabular form..

Dear Friends, I have a file as under : +++ ME 12-06-13 18:16:20 A RED FEW AND ROW1 1MN FEL AS HI FI BV LR TS HR ES MR * 0 13296 0 120 1 15 KS RR 10 0 +++ ME 12-06-13 18:26:20 A RED FEW AND ROW2 1MN FEL AS... (2 Replies)
Discussion started by: vanand420
2 Replies

8. Shell Programming and Scripting

Remove x lines form top and y lines form bottom using AWK?

How to remove x lines form top and y lines form bottom. This works, but like awk only cat file | head -n-y | awk 'NR>(x-1)' so remove last 3 lines and 5 firstcat file | head -n-3 | awk 'NR>4' (5 Replies)
Discussion started by: Jotne
5 Replies

9. Shell Programming and Scripting

Getting data in table form

Hi, I have a csv file from which i am fetching few columns as below: IFILE=/home/home1/Report1.csv OFILE=/home/home1/`date +"%m%d%y%H%M%S"`.dat if #Checks if file exists and readable then awk -F "," '(NR>4) {print $1,$6,$2,$3,$4,$5,$6}' ${IFILE} >> ${OFILE} fi cat $OFILE | mail... (7 Replies)
Discussion started by: Vivekit82
7 Replies
PPMIMGVQUANT(1) 					      General Commands Manual						   PPMIMGVQUANT(1)

NAME
ppmimgvquant - palette quantifier for Pilot Image Viewer pgm files, version 2.0. SYNOPSIS
ppmimgvquant [-4] [-h] [-v] [ppmquant options] DESCRIPTION
ppmimgvquant just calls ppmquant(1) with the following map file: P3 4 1 255 0 0 0 85 85 85 170 170 170 255 255 255 If you specify -4, then we use this map file: P3 16 1 255 0 0 0 17 17 17 34 34 34 51 51 51 68 68 68 85 85 85 102 102 102 119 119 119 136 136 136 153 153 153 170 170 170 187 187 187 204 204 204 221 221 221 238 238 238 255 255 255 The ppmquant(1) output is also passed through ppmtopgm(1) to ensure a graymap output file. OPTIONS
-4 Convert to 4 depth image (for Palm IIIx/V). -h Display a usage message and exit. -v Display the version number and exit. All other switches are passed to ppmquant(1). SEE ALSO
imgvinfo(1), imgvtopnm(1), imgvview(1), pbmtoimgv(1), pgmtoimgv(1), ppmquant(1), ppmtopgm(1), pbm(5), pgm(5). BUGS
Bug reports should be sent to Eric A. Howe (mu@trends.net). LICENSE
Copyright (C) 1997,1998 Eric A. Howe <http://www.trends.net/~mu>. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Sept 1997 PPMIMGVQUANT(1)
All times are GMT -4. The time now is 10:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy