Awk/sed script for transposing any number of rows with header row
Greetings!
I have been trying to find out a way to take a CSV file with a large number of rows, and a very large number of columns (in the thousands) and convert the rows to a single column of data, where the first row is a header representing the attribute name and the subsequent series of rows contains the value.
For instance:
In my CSV:
I am trying to get the output to be:
I found this awk code is useful:
but this combines the values:
So in the end, i want to keep them completely separate. I am sure the answer is simple, but I am new to awk/sed and am having some difficulties figuring out what the trouble is. Anybody that can help me out, I would learn tremendously from the example. Thank you in advance!!
Last edited by Franklin52; 04-24-2013 at 04:13 AM..
Reason: Please use code tags
Hi,
Tried to look for solution, and found something similar but could not adapt the solution for my needs..
I'm trying to match a pattern (in this case "ProcessType")in a logfile, then delete that line and the 4 following lines.
The logfile looks as follows:
ProcessType: PROCESS_A... (5 Replies)
Hi Experts,
The question may look very silly by seeing the title, but please have a look at it clearly.
I have a text file where the first 5 columns in each row were supposed to be attributes of a sample(like sample name, number, status etc) and the next 25 columns are parameters on which... (3 Replies)
Hi experts a have a very large file and I need to add two columns: the first one numbering the incidence of records and the another with the total count
The input file:
21 2341 A
21 2341 A
21 2341 A
21 2341 C
21 2341 C
21 2341 C
21 2341 C
21 4567 A
21 4567 A
21 4567 C
... (6 Replies)
I'm working on a different stage of a project that someone helped me address elsewhere in these threads.
The .docs I'm cycling through look roughly like this:
1 of 26 DOCUMENTS
Copyright 2010 The Age Company Limited
All Rights Reserved
The Age (Melbourne, Australia)
November 27, 2010... (9 Replies)
Hi,
I'm using AIX(ksh shell).
> cat temp.txt
"a","b",0
"c",bc",0
"a1","b1",0
"cc","cb",1
"cc","b2",1
"bb","bc",2
I want the output as:
"a","b","c","bc","a1","b1"
"cc","cb","cc","b2"
"bb","bc"
I want to combine multiple lines into single line where third column is same.
Is... (1 Reply)
Hi! Is there a way to append column and row header to a file in awk script.
For example if I have
Jane F 39 manager
Carlos M 40 system administrator
Sam F 20 programmer
and I want it to be
# name gend age occup
1 Jane F 39 manager
2 Carlos M ... (4 Replies)
I am trying to match $1-$7 between the two files and if a match is found then the contents of $8 in file2 and copied over. The awk I tried is below. There is also a header row in file2 that has the Chr Start End Ref Alt that does not need to be searched. Thank you :).
awk
awk... (3 Replies)
I am just trying to insert the word "Index" using awk. The below is close but seems to add the word at the end and I can not get the syntax correct to add from the beginning. Thank you :).
awk -F'\t' -v OFS='\t' '{ $-1=$-1 OFS "Index"}$1=$1' file
current output
Chr Start End ... (3 Replies)
The awk below does put in VUS in the 9th field but I can not seem to skip the header then add the VUS. I tried to incorporate NR >=2 and NR > 1 with no luck. Thank you :).
input
Chr Start End Ref Alt Func.refGene PopFreqMax CLINSIG Classification
chr1 43395635 ... (5 Replies)
I have a file with 48 rows. I am counting 6 rows and adding 6 to that number and repeating the operation, and then output the value in column 1. For the second column, I would like to get sort of a binary output (1s and 2s) every 3rd row. This is what I have:
awk '{print ++src +... (1 Reply)
Discussion started by: Xterra
1 Replies
LEARN ABOUT DEBIAN
color::library::dictionary::tango
Color::Library::Dictionary::Tango(3pm) User Contributed Perl Documentation Color::Library::Dictionary::Tango(3pm)NAME
Color::Library::Dictionary::Tango - (Tango) The Tango color palette
DESCRIPTION
The Tango icon theme's goal is to make applications not seem alien on any desktop. A user running a multiplatform application should not
have the impression that the look is unpolished and inconsistent with what he or she is used to. While this isn't about merging styles of
all desktop systems, we do aim to not be drastically different on each platform.
The Tango color palette consists of 27 RGB colors.
<http://tango.freedesktop.org/Tango_Icon_Theme_Guidelines>
COLORS
Aluminium 1 aluminium1 #eeeeec
Aluminium 2 aluminium2 #d3d7cf
Aluminium 3 aluminium3 #babdb6
Aluminium 4 aluminium4 #888a85
Aluminium 5 aluminium5 #555753
Aluminium 6 aluminium6 #2e3436
Butter 1 butter1 #fce94f
Butter 2 butter2 #edd400
Butter 3 butter3 #c4a000
Chameleon 1 chameleon1 #8ae234
Chameleon 2 chameleon2 #73d216
Chameleon 3 chameleon3 #4e9a06
Chocolate 1 chocolate1 #e9b96e
Chocolate 2 chocolate2 #c17d11
Chocolate 3 chocolate3 #8f5902
Orange 1 orange1 #fcaf3e
Orange 2 orange2 #f57900
Orange 3 orange3 #ce5c00
Plum 1 plum1 #ad7fa8
Plum 2 plum2 #75507b
Plum 3 plum3 #5c3566
Scarlet Red 1 scarletred1 #ef2929
Scarlet Red 2 scarletred2 #cc0000
Scarlet Red 3 scarletred3 #a40000
Sky Blue 1 skyblue1 #729fcf
Sky Blue 2 skyblue2 #3465a4
Sky Blue 3 skyblue3 #204a87
perl v5.14.2 2011-12-07 Color::Library::Dictionary::Tango(3pm)