Sponsored Content
Full Discussion: Pivot file content
Top Forums Shell Programming and Scripting Pivot file content Post 302654869 by neutronscott on Tuesday 12th of June 2012 10:58:45 AM
Old 06-12-2012
I added a couple entries to the bottom to test robustness..
Code:
A "99"
F "101"

Code:
[mute@geek ~]$ ./pivot input
A       B       C       D       E       F
1       2       3       4       5       6
11      21      31      41      51      61
99                                      101

it's an awk program.
Code:
#!/usr/bin/awk -f
!($1 in a){a[$1]=c;b[c++]=$1}
{gsub(/(^"|"$)/,"",$2);matrix[$1,d[$1]++]=$2}
END {
  for (i = 0; i < c; i++) {
    printf("%s\t", b[i]);
    if (d[b[i]] > max) max=d[b[i]]
  }
  printf("\n")
  for (i = 0; i < max; i++) {
    for (j = 0; j < c; j++)
      printf("%s\t", matrix[b[j],i])
    printf("\n")
  }
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Pivot file to flat file

I have a file in this format. P1 P2 P3......................... A001 v11 v21 v31...................... A002 v12 v22 v32............................ A003 v13 v23 v33.......................... A004 v14 v24 v34.............................. . . . A00n... (2 Replies)
Discussion started by: vskr72
2 Replies

2. Shell Programming and Scripting

pivot

I have a sql table with : Acitvity Date Value ABC 7/11 10 DEF 7/11 98 ABC 7/12 23 DEF 7/12 100 SER 7/12 67 GRH 7/13 123 HJY 7/14 12 I... (4 Replies)
Discussion started by: mukhanj
4 Replies

3. Shell Programming and Scripting

Pivot variable record length file and change delimiter

Hi experts. I got a file (500mb max) and need to pivot it (loading into ORCL) and change BLANK delimiter to PIPE |. Sometimes there are multipel BLANKS (as a particular value may be BLANK, or simply two BLANKS instead of one BLANK). thanks for your input! Cheers, Layout... (3 Replies)
Discussion started by: thomasr
3 Replies

4. Shell Programming and Scripting

Pivot file contents

Hi All, I am trying to pivot the contents in a file. Ex: I have a file sample.txt with data "A B C D", i need the contents to pivot & resulting file should look like "A B C ... (3 Replies)
Discussion started by: new_ds_man
3 Replies

5. UNIX for Dummies Questions & Answers

Script to pivot flat file

Hi to all, I have a file with a list of values: v1,v2,v3....,v9 need file in this format: Name1: v1 Name2: v2 Name3: v3 ... Name9: v9 Please help me out. (2 Replies)
Discussion started by: mozi
2 Replies

6. Shell Programming and Scripting

Sed: replace content from file with the content from file

Hi, I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C. Thanks a lot!! Here is a sample of my question. e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies

7. Shell Programming and Scripting

How to remove exisiting file content from a file and have to append new file content?

hi all, i had the below script x=`cat input.txt |wc -1` awk 'NR>1 && NR<'$x' ' input.txt > output.txt by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

8. Shell Programming and Scripting

Create a pivot table from CSV file

Gents, Can you please help me to create a pivot table from a csv file. ( I have zip the csv file) Using the file attached, columns 1,28 and 21 i would like to get something like this output JD Val 1 2 3 4 5 6 7 8 9 10 11 12 Total... (4 Replies)
Discussion started by: jiam912
4 Replies

9. Shell Programming and Scripting

Pivot file using shellscript

Hi, I am new at using shell scripting. So I have a question for the more experienced Linux users. I would like to perform some kind of pivot on a file. Example Input file COL1,"2001-01-01","2001-03-01","2001-03-24" A1,22,,44 B1,56,78,12 C2,5,, I would like to have to following output... (2 Replies)
Discussion started by: shanlinux
2 Replies

10. Shell Programming and Scripting

Pivot example

Hi all, I am new to shell scripting so pardon me for the questions I will be asking. I was given a task where I have to pivot my data Example Source SGPAPCTUMACCHEA Expected output SGP APC TUM SGP APC ACC SGP APC HEA Can anybody assist me on this?Please use CODE tags as required... (3 Replies)
Discussion started by: redaela
3 Replies
slanst.f(3)							      LAPACK							       slanst.f(3)

NAME
slanst.f - SYNOPSIS
Functions/Subroutines REAL function slanst (NORM, N, D, E) SLANST returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real symmetric tridiagonal matrix. Function/Subroutine Documentation REAL function slanst (characterNORM, integerN, real, dimension( * )D, real, dimension( * )E) SLANST returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real symmetric tridiagonal matrix. Purpose: SLANST returns the value of the one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real symmetric tridiagonal matrix A. Returns: SLANST SLANST = ( max(abs(A(i,j))), NORM = 'M' or 'm' ( ( norm1(A), NORM = '1', 'O' or 'o' ( ( normI(A), NORM = 'I' or 'i' ( ( normF(A), NORM = 'F', 'f', 'E' or 'e' where norm1 denotes the one norm of a matrix (maximum column sum), normI denotes the infinity norm of a matrix (maximum row sum) and normF denotes the Frobenius norm of a matrix (square root of sum of squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. Parameters: NORM NORM is CHARACTER*1 Specifies the value to be returned in SLANST as described above. N N is INTEGER The order of the matrix A. N >= 0. When N = 0, SLANST is set to zero. D D is REAL array, dimension (N) The diagonal elements of A. E E is REAL array, dimension (N-1) The (n-1) sub-diagonal or super-diagonal elements of A. Author: Univ. of Tennessee Univ. of California Berkeley Univ. of Colorado Denver NAG Ltd. Date: September 2012 Definition at line 101 of file slanst.f. Author Generated automatically by Doxygen for LAPACK from the source code. Version 3.4.2 Tue Sep 25 2012 slanst.f(3)
All times are GMT -4. The time now is 02:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy