我有这样的CSV文件:
(SELECT ID,
Name,
Prod AS Item,
Cost
FROM red_table)
UNION ALL
(SELECT ID,
Title AS Name,
Item,
'' AS Cost
FROM blue_table)
ORDER BY ID ASC
我想将用逗号分隔符的每个数据拆分到新列。像这样:
Operator_Code
A
AA
AA,HB
AB,AX
AC
AD
AE,SJ,AX,VV
AF,SA,SP
AG
AG,SA
AK
AK,MA,CN,FA,AX
我应该如何用awk或其他方式进行操作。 谢谢高级...
答案 0 :(得分:0)
假设您知道最大列数,可能是
# printf "Col1\tCol2\tCol3\tCol4\tCol5"; gawk -F"," '{print $1"\t"$2"\t"$3"\t"$4"\t"$5}' infile
Col1 Col2 Col3 Col4 Col5A
AA
AA HB
AB AX
AC
AD
AE SJ AX VV
AF SA SP
AG
AG SA
AK
AK MA CN FA AX