Sponsored Content
Top Forums Shell Programming and Scripting How transpose column in a row? Post 303027996 by Salvatore_espos on Saturday 29th of December 2018 05:55:33 AM
Old 12-29-2018
Hi guys,
First of all I would say thank you to both. I'm sorry if I didn't explain well the problem and of course I've thought about it, but it was not easy explain it fully. I try to better explain the problem and what I've done.
I read what RudiC suggested, and I studied the following code on my table:

Code:
BEGIN { FS = OFS = "|" }
{ for (fld = 1; fld <= NF; fld++) {
  print $0
  }
}

After that my file changed from its native form:
Code:
VIT_AGLc1g09770.1    GO:0016491|GO:0055114
VIT_AGLc9g366030.1    GO:0004665|GO:0006571|GO:0008977|GO:0055114
VIT_AGLc6g304750.1    GO:0005515
VIT_AGLc1g09770.2    GO:0016491|GO:0055114
VIT_AGLc11g42510.1    GO:0004427|GO:0009678|GO:0015992|GO:0016020
VIT_AGLc11g41480.1    GO:0004672|GO:0005524|GO:0006468
VIT_AGLc1g09770.3    GO:0016491|GO:0055114
VIT_AGLc6g304750.3    GO:0005515
VIT_AGLc1g09770.4    GO:0016491|GO:0055114
VIT_AGLc5g276360.1    GO:0004672|GO:0005524|GO:0006468

To:

Code:
VIT_AGLc1g09770.1    GO:0016491|GO:0055114
VIT_AGLc1g09770.1    GO:0016491|GO:0055114
VIT_AGLc9g366030.1    GO:0004665|GO:0006571|GO:0008977|GO:0055114
VIT_AGLc9g366030.1    GO:0004665|GO:0006571|GO:0008977|GO:0055114
VIT_AGLc9g366030.1    GO:0004665|GO:0006571|GO:0008977|GO:0055114
VIT_AGLc9g366030.1    GO:0004665|GO:0006571|GO:0008977|GO:0055114
VIT_AGLc6g304750.1    GO:0005515
VIT_AGLc1g09770.2    GO:0016491|GO:0055114
VIT_AGLc1g09770.2    GO:0016491|GO:0055114


Hence, each time that I have a field (in the second column of my table, separated by |) > 1, it prints the row for the maximum number of field.
This a part of what I was looking for and I was happy to got it. However, I should have in the second column, only one field "each time"
Indeed the expected results should look like this:

Code:
VIT_AGLc1g09770.1    GO:0016491
VIT_AGLc1g09770.1    GO:0055114
VIT_AGLc9g366030.1    GO:0004665
VIT_AGLc9g366030.1    GO:0006571
VIT_AGLc9g366030.1    GO:0008977
VIT_AGLc9g366030.1    GO:0055114
VIT_AGLc6g304750.1    GO:0005515
VIT_AGLc1g09770.2    GO:0016491
VIT_AGLc1g09770.2    GO:0055114

Anyway I m grateful to both.

Last edited by RudiC; 12-29-2018 at 05:23 PM.. Reason: Added (a few) CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Row to column transpose

Can we transpose rows to columns? Fields within row are separated by a comma. (10 Replies)
Discussion started by: videsh77
10 Replies

2. Shell Programming and Scripting

Transpose column to row

Hi i have a file which has values seperated by "," as shown below and I want to transpose for every doc_id in one row. Input: DOC_ID,KEYWORD 105,REGISTROS 105,GEOLOGIA 105,NUCLEOS 105,EXPEDIENTE 105,PROGRAMAS 10025,EXPEDIENTE 10025,LOCALIZACIONES 10025,OFICIOS 10025,PROGRAMAS... (4 Replies)
Discussion started by: juelillo
4 Replies

3. Shell Programming and Scripting

Row to column transpose between same pattern.

Hi All, I have been trying to transpose rows to column in an large file (about 15000 lines) between matching pattern. Searched all posts in this forum, but not able find the solution to my problem. Any help appreciated.!! Input /*------XXXXXX-------*/ owner: XXXX location: XXXX... (3 Replies)
Discussion started by: RobP
3 Replies

4. UNIX for Dummies Questions & Answers

Row to column transpose

Hi there, Below is sample three rows which i need transpose into multiple rows. By keeping first 2 fields static and split them into multiple rows depend following date field. Each into seperate rows. Sample code: ... (6 Replies)
Discussion started by: ganeshd
6 Replies

5. Shell Programming and Scripting

Column to row Transpose

Hi Folks, Iam a kinda newbie to unix shell scripting, the scenario is i have a text file containing the following info Charlie chicago 15 Charlie newyork 26 jonny chicago 14 jonny newyork 15 joe chicago 15 joe newyork 18output should be Name chicago ... (3 Replies)
Discussion started by: tech_frk
3 Replies

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

7. Shell Programming and Scripting

To transpose row into column

Hi All, In shell, I have below data coming from some some text file as below: . 351706 5861.8 0.026 0.012 12.584 0.026 0.012 12.582 0.000 0.000 0.000 Now i need the above data to be transposed as below 351706... (16 Replies)
Discussion started by: Anamica
16 Replies

8. Shell Programming and Scripting

Transpose row to column

I'm using the testawk.awk from the following thread https://www.unix.com/shell-programming-and-scripting/18897-row-column-transpose.htmlI'm getting the following output fieldname1 data1 fieldname2 data2 fieldname3 data3 How can I get like this instead 1 fieldname1 data1 2 fieldname2 data2... (1 Reply)
Discussion started by: makkan
1 Replies

9. Shell Programming and Scripting

Transpose from row to column using timestamp in first column

Gents, Transpose from row to column, taking in consideration the first column, which contends the date. Input file 72918,111000009,111000009,111000009,111000009,111000009,111000009,111000009,111000009,111000009 72918,2356,2357,2358,2359,2360,2361,2362,2363,2364 72918,0,0,0,0,0,0,0,0,0... (12 Replies)
Discussion started by: jiam912
12 Replies

10. UNIX for Beginners Questions & Answers

Transpose the Row and column

Hi, I have data in form of A ram B shyam C seeta D geeta A bob B methew C Richad D Mike and i want it in this form. A B C D ram shyam seeta geeta bob methew Richard Mike. please help by providing the scripting for this. (3 Replies)
Discussion started by: ricbha
3 Replies
Locale::Codes::LangFam(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangFam(3pm)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2012 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 Locale::Codes::LangFam(3pm)
All times are GMT -4. The time now is 03:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy