其他分享
首页 > 其他分享> > bash transpose csv

bash transpose csv

作者:互联网

transpose()
{
awk '
BEGIN {
FS = ",";
OFS = ",";
}

{
if (max_nf<NF)
max_nf=NF
max_nr=NR
for (x=1; x<=NF; ++x)
vector[x, NR]=$x
}

END {
for (x=1; x<=max_nf; ++x) {
for (y=1; y<=max_nr; ++y)
printf("%s,", vector[x, y])
printf("\n")
}
}' ${1}
}

transpose ${1}

https://stackanswers.net/questions/how-to-do-a-transpose-in-bash-awk-other-duplicate

标签:max,transpose,nf,awk,printf,NR,csv,bash
来源: https://www.cnblogs.com/3Dgenome/p/15125376.html