Sponsored Content
Top Forums Shell Programming and Scripting Transpose matrix based on second column using awk Post 302934738 by RavinderSingh13 on Tuesday 10th of February 2015 08:26:16 AM
Old 02-10-2015
Hello quincyjones,

Could you please try following and let us know if this helps.
Code:
awk '{X[$1];Y[$2];Z[$1,$2]=$3}
END{
printf "%20s",""; for(i in X) printf "%10s",i;print "";
for(j in Y) {printf "%10s",j;printf "%10s",""
for(i in X) printf "%10s",Z[i,j];print "";}
}' Input_file

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

two-column data to matrix in AWK

Howdy, I need to convert an association data matrix, currently in a two-column format, into a matrix with numbers indicating the number of associations. I've been looking around for AWK code in the list, but could not find anything. Here's an example of what I want to perform: original... (10 Replies)
Discussion started by: sramirez
10 Replies

2. Shell Programming and Scripting

awk: Transpose csv row to column.

Hello, am I new to awk, and I am tryint to: INPUT FILE: "73423555","73423556","73423557","73423558","73423559" OUTPUT FILE: 73423555 73423556 73423557 73423558 73423559 My useless code so far: #!/bin/awk -F ',' BEGIN { i=0; } (8 Replies)
Discussion started by: drbiloukos
8 Replies

3. Shell Programming and Scripting

awk transpose rows to column

Need to transpose in awk rows to column like this: input: A1,6,5,4 3,2,1, A2,8,7,9,10,11,12,13,14 A3,1,2,3,5,7,8,9 A4,9,4,8,1,5,3, output: A1,1 A1,2 A1,4 ... A2,7 A2,8 ... A3,1 A3,2 ... A4,1 A4,3 (5 Replies)
Discussion started by: sdf
5 Replies

4. Shell Programming and Scripting

awk transpose row into 2 field column

Need to transpose every 2 fields of a row into a single 2 field column. input 4 135 114 76 217 30 346 110 5 185 115 45 218 85 347 125 6 85 116 130 220 65 352 95 11 30 117 55 221 42 355 75 16 72 118 55 224 37 357 430 17 30 119 55 225 40 358 62 21 52 120 65 232 480 360 180 ....... (8 Replies)
Discussion started by: sdf
8 Replies

5. Shell Programming and Scripting

Matrix transpose

Hello to everyone! I'm pretty tired and I cannot concentrate properly, but I need some help!!! I have a matrix like the one in the attachment (matrice_prova) and I would like an output like this: L1 L1 0.0 L1 L2 2.1 L1 L3 3.1 L1 L4 3.2 .... How is it possible do that in Perl or Awk?? Any... (3 Replies)
Discussion started by: gabrysfe
3 Replies

6. Shell Programming and Scripting

3 column .csv --> correlation matrix; awk, perl?

Greetings, salutations. I have a 3 column csv file with ~13 million rows and I would like to generate a correlation matrix. Interestingly, you all previously provided a solution to the inverse of this problem. Thread title: "awk? adjacency matrix to adjacency list / correlation matrix to list"... (6 Replies)
Discussion started by: R3353
6 Replies

7. Shell Programming and Scripting

Transpose timestamp based on column values and calculate time difference

Hello Expert, I need to transpose Date-Timestamp based on same column values and calculate time difference. The input file would be as below and required output is mentioned in the bottom INPUT File ======== 08/23/2012 12:36:09 JOB_5340 08/23/2012 12:36:14 JOB_5340 08/23/2012... (2 Replies)
Discussion started by: asnandhakumar
2 Replies

8. 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

9. Shell Programming and Scripting

Transpose column to row - awk

Hi there, I have a small csv file example below: source,cu_001,cu_001_volume,cu_001_mass,cu_002,cu_002_volume,cu_002_mass,cu_003,cu_003_volume,cu_003_mass ja116,1.33,3024000,9374400,1.54,3026200,9375123,1.98,3028000,9385512 I want to transpose columns to rows starting at the second... (3 Replies)
Discussion started by: theflamingmoe
3 Replies

10. Shell Programming and Scripting

awk transpose column to row and sort

I am trying to awk the output from below output for each port: i need separate line with comma source file Output required (3 Replies)
Discussion started by: ranjancom2000
3 Replies
STRSYL(l)								 )								 STRSYL(l)

NAME
STRSYL - solve the real Sylvester matrix equation SYNOPSIS
SUBROUTINE STRSYL( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C, LDC, SCALE, INFO ) CHARACTER TRANA, TRANB INTEGER INFO, ISGN, LDA, LDB, LDC, M, N REAL SCALE REAL A( LDA, * ), B( LDB, * ), C( LDC, * ) PURPOSE
STRSYL solves the real Sylvester matrix equation: op(A)*X + X*op(B) = scale*C or op(A)*X - X*op(B) = scale*C, where op(A) = A or A**T, and A and B are both upper quasi- triangular. A is M-by-M and B is N-by-N; the right hand side C and the solution X are M-by-N; and scale is an output scale factor, set <= 1 to avoid overflow in X. A and B must be in Schur canonical form (as returned by SHSEQR), that is, block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; each 2-by-2 diagonal block has its diagonal elements equal and its off-diagonal elements of opposite sign. ARGUMENTS
TRANA (input) CHARACTER*1 Specifies the option op(A): = 'N': op(A) = A (No transpose) = 'T': op(A) = A**T (Transpose) = 'C': op(A) = A**H (Conjugate transpose = Transpose) TRANB (input) CHARACTER*1 Specifies the option op(B): = 'N': op(B) = B (No transpose) = 'T': op(B) = B**T (Transpose) = 'C': op(B) = B**H (Conjugate transpose = Transpose) ISGN (input) INTEGER Specifies the sign in the equation: = +1: solve op(A)*X + X*op(B) = scale*C = -1: solve op(A)*X - X*op(B) = scale*C M (input) INTEGER The order of the matrix A, and the number of rows in the matrices X and C. M >= 0. N (input) INTEGER The order of the matrix B, and the number of columns in the matrices X and C. N >= 0. A (input) REAL array, dimension (LDA,M) The upper quasi-triangular matrix A, in Schur canonical form. LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,M). B (input) REAL array, dimension (LDB,N) The upper quasi-triangular matrix B, in Schur canonical form. LDB (input) INTEGER The leading dimension of the array B. LDB >= max(1,N). C (input/output) REAL array, dimension (LDC,N) On entry, the M-by-N right hand side matrix C. On exit, C is overwritten by the solution matrix X. LDC (input) INTEGER The leading dimension of the array C. LDC >= max(1,M) SCALE (output) REAL The scale factor, scale, set <= 1 to avoid overflow in X. INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value = 1: A and B have common or very close eigenvalues; perturbed values were used to solve the equation (but the matrices A and B are unchanged). LAPACK version 3.0 15 June 2000 STRSYL(l)
All times are GMT -4. The time now is 10:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy