Sponsored Content
Full Discussion: awk transpose rows to column
Top Forums Shell Programming and Scripting awk transpose rows to column Post 302568615 by rdcwayx on Thursday 27th of October 2011 08:07:12 PM
Old 10-27-2011
I guess the result need be sorted.
Code:
awk -F , '{for (i=2;i<=NF;i++) if ($i>=0) print $1 FS $i|"sort -t, -k1,1 -k2,2n"}' infile

A1,1
A1,2
A1,4 3
A1,5
A1,6
A2,7
A2,8
A2,9
A2,10
A2,11
A2,12
A2,13
A2,14
A3,1
A3,2
A3,3
A3,5
A3,7
A3,8
A3,9
A4,1
A4,3
A4,4
A4,5
A4,8
A4,9


Last edited by rdcwayx; 10-27-2011 at 09:24 PM..
This User Gave Thanks to rdcwayx For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Transpose Datefield from rows to column + Print time diff

Hi Experts, Can you please help me in transposing Datefield from rows to column and calculate the time difference for each of the Jobids: Input File: 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012 12:36:26,JOB_5350 Required Output:... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

2. Shell Programming and Scripting

awk to transpose preceding row to 1st column of next rows

Gurus: How can I transpose the output below to a format in which I can plot a graph to show VSZ memory usage by PIDs? stdout: Tue Jan 22 07:29:19 CUT 2013 42336296 1841272 java wilyadm 21889232 438616 jlaunch sidadm 42532994 414336 jlaunch sidadm Tue Jan 22 07:49:20 CUT 2013... (1 Reply)
Discussion started by: ux4me
1 Replies

3. Shell Programming and Scripting

Transpose Column of Data to Rows

I can no longer find my commands, but I use to be able to transpose data with common fields from a single column to rows using a command line. My data is separated as follows: NAME=BOB ADDRESS=COLORADO PET=CAT NAME=SUSAN ADDRESS=TEXAS PET=BIRD NAME=TOM ADDRESS=UTAH PET=DOG I would... (7 Replies)
Discussion started by: docdave78
7 Replies

4. Shell Programming and Scripting

Transpose multiple rows (with a mix of space and enter) to a single column

How to change the uploaded weekly file data to the following format? New Well_Id,Old Well_Id,District,Thana,Date,Data,R.L,WellType,Lati.,Longi. BAG001,PT006,BARGUNA,AMTALI,1/2/1978,1.81,2.29,Piezometer,220825,901430 BAG001,PT006,BARGUNA,AMTALI,1/9/1978,1.87,2.29,Piezometer,220825,901430... (3 Replies)
Discussion started by: sara.nowreen
3 Replies

5. Shell Programming and Scripting

awk to transpose every 7 rows into columns

input: a1 a2 a3 a4 a5 a6 a7 b1 b2 b3 .. b7 .. z1 .. z7 (12 Replies)
Discussion started by: ux4me
12 Replies

6. Shell Programming and Scripting

Transpose data as rows using awk

Hi I have below requirement, need help One file contains the meta data information and other file would have the data, match the column from file1 and with file2 and extract corresponding column value and display in another file File1: CUSTTYPECD COSTCENTER FNAME LNAME SERVICELVL ... (1 Reply)
Discussion started by: ravlapo
1 Replies

7. Shell Programming and Scripting

Peel syntax for transpose rows into column

Dear all, Plz let me know syntax for transposing rows into column in perl, I am having 30 csv files which are merged into a single xls sheet. but i want to transpose each row into column in excel sheet in each tab (1 CSV = 1tab in xls sheet) example is as below ... (0 Replies)
Discussion started by: sagar_1986
0 Replies

8. Programming

To transpose rows to column in hadoop

Hi, i am having an HDFS file which is comma seperated, i need to transpose from rows to column only the header columns text.csv cnt,name,place 1,hi,nz 2,hello,aus I need cnt, name, place while using below command in hadoop getting the error hadoop fs -fmt -1 text.csv (0 Replies)
Discussion started by: rohit_shinez
0 Replies

9. Shell Programming and Scripting

Linux - Transpose rows into column

hello, I have a server that collect some performance statistics of 4 servers in the following input file : $ cat inputfile Time,A,Server1,KPI1,data1 Time,A,Server1,KPI2,data2 Time,A,Server1,KPI3,data3 Time,A,Server1,KPI4,data4 Time,A,Server1,KPI5,data5 Time,A,Server2,KPI1,data6... (9 Replies)
Discussion started by: capitain25
9 Replies

10. UNIX for Beginners Questions & Answers

How to transpose pieces of data in a column to multiple rows?

Hello Everyone, I am very new to the world of regular expressions. I am trying to use grep/sed for the following: Input file is something like this and there are multiple such files: abc 1 2 3 4 5 ***END*** abc 6 7 8 9 ***END*** abc 10 (2 Replies)
Discussion started by: shellnewuser
2 Replies
TRANSPOSE(9.1)															    TRANSPOSE(9.1)

NAME
rotate, transpose - re-orient an image SYNOPSIS
fb/rotate angle [ input ] fb/transpose [ -vhadrlui ] [ -ox y ] [ input ] DESCRIPTION
Rotate rotates the image in its input picture file (default standard input) clockwise by angle degrees, writing the resulting picture file on standard output. Transpose turns its input picture file on its side by reflection through its major (descending from left to right) diagonal, writing the resulting picture file on standard output. If no file name is given, the picture is read from standard input. Options yield all possible symmetries of the square grid: -d reflects the image through its descending diagonal (the default). -a reflects the image through its ascending diagonal. -v reflects the image left-to-right through its vertical center line. -h inverts the image top-to-bottom through its horizontal center line. -r rotates the image to the right (clockwise) 90 degrees. -l rotates the image to the left (counterclockwise) 90 degrees. -u rotates the image upside down (180 degrees). -i identity transformation (for completeness only.) -o x y translates by (x,y). Without -o, the input and output files have the same upper-left corner. Transpose is particularly useful to convince programs that work on the rows of a picture file to operate on columns. For example fb/transpose big | fb/resample 48 | fb/transpose | fb/resample 48 >tiny makes a tiny 48x48 version of a big picture. SOURCE
/sys/src/fb/rotate.c /sys/src/fb/transpose.c SEE ALSO
picfile(9.6), resample(9.1) BUGS
Very large images may not fit in memory. The result of rotate is not anti-aliased. TRANSPOSE(9.1)
All times are GMT -4. The time now is 09:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy