Sponsored Content
Full Discussion: Transpose a file
Top Forums UNIX for Dummies Questions & Answers Transpose a file Post 302948362 by rbatte1 on Monday 29th of June 2015 09:57:49 AM
Old 06-29-2015
This is not really what I would call a simple transposing function (flipping columns to rows and vice-versa) but you are looking to tabulate the input.

You could use arrays if you can be certain of the rows & columns you want to look for. You can then read the input and set a flag in the appropriate row/column of the array depending on what you read. Finally, you display the table based on the array values, just looping round them.


What have you tried so far?
What are you comfortable using/supporting? For example ksh only, perl, awk, sed, C?

For "plate" do you mean the column marked "Assay"?

Can you logically define the process you want to follow? If you can then with refinement we can work out the code you need.


Sorry for the questions, but I would prefer to get a good solution that you can maintain in future rather than just going "Ta-da!" and you have no idea how it works and I have no idea if it meets your needs when you have data that is larger than the sample.




Robin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

transpose file

Hi all, I have a file in the below format.... <A> B C <A> E F <A> G H I need the result file to be: <A>BC <A>EF <A>GH (3 Replies)
Discussion started by: new_ds_man
3 Replies

2. Shell Programming and Scripting

Transpose an entire text file

Hello all, I want to transpose the rows of a file to the columns (every characters include spaces), i.e.: input: abcdefg 123 456 output: a1 b2 c3 d e4 f5 g6 I wrote a script: #!/bin/csh -f (15 Replies)
Discussion started by: heavenfish
15 Replies

3. Shell Programming and Scripting

File Transpose

Hi ALL I have one input file say FILE1 which looks as below. a=1 b=2 c=3 a=4 b=5 c=6 . . . Here a,b,c...etc are variable names. The output file(FILE2) should look like 1,2,3 4,5,6 ..... ..... (5 Replies)
Discussion started by: 46019
5 Replies

4. Shell Programming and Scripting

Rows to Columns - File Transpose

Hi I have an input file and I want to transpose it but I need to take care that if any field is missing for a record it should be popoulated with space for that field - using a shell script INFILE ---------- emp=1 sal=2 loc=abc emp=2 sal=21 sal=22 loc=xyz emp=5 loc=abc OUTFILE... (10 Replies)
Discussion started by: 46019
10 Replies

5. Shell Programming and Scripting

Transpose a file

input IndID ID1 ID2 ID3 a1 a/a b/b c/c a2 a/a b/b c/c a3 a/b b/b c/d a6 a/b b/b c/e a8 a/a b/c c/e a9 b/b b/d c/e output IDName IndID IDtype C_No ID1 a1 a/a 1 ID1 a2 a/a 1 ID1 a8 ... (1 Reply)
Discussion started by: stateperl
1 Replies

6. Shell Programming and Scripting

Transpose a text file.

Hello, I have a text file which is like a matrix m rows and n columns. Now I want to convert it into n rows and m columns. Thanks for hint. (1 Reply)
Discussion started by: zhshqzyc
1 Replies

7. Shell Programming and Scripting

Transpose whole file and specific columns

Hi, I have a file like this a b c d e f g h i j k l Case1: I want to transpose the whole file Output1 a d g j b e h k c f i l Case2 Transpose a specific column - Say 3rd (6 Replies)
Discussion started by: jacobs.smith
6 Replies

8. Shell Programming and Scripting

File transpose problem

Hi Friends, I have a file with a structure like this: <file1.csv> field1,field2,field3,field4,field5,field6,field7,field8,field9,field10,field11,field12 Few Salient points on the file's structure (1)The fields from field1 to field6 is fixed and they would always be present in the file... (2 Replies)
Discussion started by: mehimadri12
2 Replies

9. UNIX for Dummies Questions & Answers

Transpose File

Have various files like this: InSlot=0x00000001 InPort=0x00000000 Inref=0x0000002f InSID=0x00000001 OutSlot=0x00000001 OutPort=0x00000002 Outref=0x00000000 OutSID=0x0000000b OutUName_2=14 InSlot=0x00000001 InPort=0x00000000 Inref=0x000001a8 InSID=0x00000001 OutSlot=0x00000001... (5 Replies)
Discussion started by: K@rlos
5 Replies

10. Shell Programming and Scripting

Transpose a txt file

Hello, I have a text file with 148 rows and 2532691 columns. I need to transpose the data. The command that I am using is awk ' { for (i=1; i<=NF; i++) { a = $i } } NF>p { p = NF } END { for(j=1; j<=p; j++) { str=a for(i=2; i<=NR; i++){ ... (6 Replies)
Discussion started by: nans
6 Replies
PZLASWP(l)					      LAPACK auxiliary routine (version 1.5)						PZLASWP(l)

NAME
PZLASWP - perform a series of row or column interchanges on the distributed matrix sub( A ) = A(IA:IA+M-1,JA:JA+N-1) SYNOPSIS
SUBROUTINE PZLASWP( DIREC, ROWCOL, N, A, IA, JA, DESCA, K1, K2, IPIV ) CHARACTER DIREC, ROWCOL INTEGER IA, JA, K1, K2, N INTEGER DESCA( * ), IPIV( * ) COMPLEX*16 A( * ) PURPOSE
PZLASWP performs a series of row or column interchanges on the distributed matrix sub( A ) = A(IA:IA+M-1,JA:JA+N-1). One interchange is initiated for each of rows or columns K1 trough K2 of sub( A ). This routine assumes that the pivoting information has already been broad- cast along the process row or column. Also note that this routine will only work for K1-K2 being in the same MB (or NB) block. If you want to pivot a full matrix, use PZLAPIV. Notes ===== Each global data object is described by an associated description vector. This vector stores the information required to establish the mapping between an object element and its corresponding process and memory location. Let A be a generic term for any 2D block cyclicly distributed array. Such a global array has an associated description vector DESCA. In the following comments, the character _ should be read as "of the global array". NOTATION STORED IN EXPLANATION --------------- -------------- -------------------------------------- DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case, DTYPE_A = 1. CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating the BLACS process grid A is distribu- ted over. The context itself is glo- bal, but the handle (the integer value) may vary. M_A (global) DESCA( M_ ) The number of rows in the global array A. N_A (global) DESCA( N_ ) The number of columns in the global array A. MB_A (global) DESCA( MB_ ) The blocking factor used to distribute the rows of the array. NB_A (global) DESCA( NB_ ) The blocking factor used to distribute the columns of the array. RSRC_A (global) DESCA( RSRC_ ) The process row over which the first row of the array A is distributed. CSRC_A (global) DESCA( CSRC_ ) The process column over which the first column of the array A is distributed. LLD_A (local) DESCA( LLD_ ) The leading dimension of the local array. LLD_A >= MAX(1,LOCr(M_A)). Let K be the number of rows or columns of a distributed matrix, and assume that its process grid has dimension p x q. LOCr( K ) denotes the number of elements of K that a process would receive if K were distributed over the p processes of its process col- umn. Similarly, LOCc( K ) denotes the number of elements of K that a process would receive if K were distributed over the q processes of its process row. The values of LOCr() and LOCc() may be determined via a call to the ScaLAPACK tool function, NUMROC: LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ), LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ). An upper bound for these quantities may be computed by: LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A ARGUMENTS
DIREC (global input) CHARACTER Specifies in which order the permutation is applied: = 'F' (Forward) = 'B' (Backward) ROWCOL (global input) CHARACTER Specifies if the rows or columns are permuted: = 'R' (Rows) = 'C' (Columns) N (global input) INTEGER If ROWCOL = 'R', the length of the rows of the distributed matrix A(*,JA:JA+N-1) to be permuted; If ROWCOL = 'C', the length of the columns of the distributed matrix A(IA:IA+N-1,*) to be permuted. A (local input/local output) COMPLEX*16 pointer into the local memory to an array of dimension (LLD_A, * ). On entry, this array contains the local pieces of the distri- buted matrix to which the row/columns interchanges will be applied. On exit the permuted distributed matrix. IA (global input) INTEGER The row index in the global array A indicating the first row of sub( A ). JA (global input) INTEGER The column index in the global array A indicating the first column of sub( A ). DESCA (global and local input) INTEGER array of dimension DLEN_. The array descriptor for the distributed matrix A. K1 (global input) INTEGER The first element of IPIV for which a row or column inter- change will be done. K2 (global input) INTEGER The last element of IPIV for which a row or column inter- change will be done. IPIV (local input) INTEGER array, dimension LOCr(M_A)+MB_A for row pivoting and LOCc(N_A)+NB_A for column pivoting. This array is tied to the matrix A, IPIV(K) = L implies rows (or columns) K and L are to be interchanged. LAPACK version 1.5 12 May 1997 PZLASWP(l)
All times are GMT -4. The time now is 09:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy