I have a huge tab-separated file formatted like this
X column1 column2 column3
row1 0 1 2
row2 3 4 5
row3 6 7 8
row4 9 10 11
I would like t
I normally use this little awk
snippet for this requirement:
awk '{for (i=1; i<=NF; i++) a[i,NR]=$i
max=(max
This just loads all the data into a bidimensional array a[line,column]
and then prints it back as a[column,line]
, so that it transposes the given input.
This needs to keep track of the max
imum amount of columns the initial file has, so that it is used as the number of rows to print back.