ste

Једноставни уређивач табела
git clone https://git.sr.ht/~strahinja/ste
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

transpose (536B)


      1 #!/usr/bin/awk -f
      2 # transpose - Transpose a TSV file
      3 # This program is licensed under the terms of GNU GPL v3 or (at your option)
      4 # any later version. Copyright (C) 2023-2026  Страхиња Радић.
      5 # See the file LICENSE for exact copyright and license details.
      6 BEGIN { FS="\t" }
      7 {
      8 	if (cols < NF)
      9 		cols = NF
     10 	rows = NR
     11 	for (x = 1; x <= NF; x++)
     12 		table[rows, x] = $x
     13 }
     14 END {
     15 	for (x = 1; x <= cols; x++)
     16 	{
     17 		for (y = 1; y <= rows; y++)
     18 		{
     19 			printf "%s", table[y, x]
     20 			if (y != rows)
     21 				printf "\t"
     22 		}
     23 		printf "\n"
     24 	}
     25 }