具有以下格式的数据
Code Name
C-123456 XYS Contracting
31-Mar-17 CNC/SIV45678/CNC/SI-45678
21-Dec-17 CNC/SIV7894/CNC/SI-7894
21-Dec-17 CNC/SIV12348/CNC/SI-12348
31-May-18 CNC/SIV23458/CNC/SI-23458
31-May-18 CNC/SIV3456/CNC/SI-3456
30-Jun-18 CNC/SIV56789/CNC/SI-56789
30-Jun-18 CNC/SIV1346/CNC/SI-1346
14-Aug-18 CNC/FTIV00198/CNC/FTI00198
14-Aug-18 CNC/FTIV00199/CNC/FTI00199
31-Aug-18 CNC/SIV30964/CNC/SI-30964
Total due
我需要以下格式的数据
Code Name Date Invoice Number
C-123456 XYS Contracting 31-Mar-17 CNC/SIV45678/CNC/SI-45678
C-123456 XYS Contracting 21-Dec-17 CNC/SIV7894/CNC/SI-7894
C-123456 XYS Contracting 21-Dec-17 CNC/SIV12348/CNC/SI-12348
C-123456 XYS Contracting 31-May-18 CNC/SIV23458/CNC/SI-23458
C-123456 XYS Contracting 31-May-18 CNC/SIV3456/CNC/SI-3456
C-123456 XYS Contracting 30-Jun-18 CNC/SIV56789/CNC/SI-56789
C-123456 XYS Contracting 30-Jun-18 CNC/SIV1346/CNC/SI-1346
C-123456 XYS Contracting 14-Aug-18 CNC/FTIV00198/CNC/FTI00198
C-123456 XYS Contracting 14-Aug-18 CNC/FTIV00199/CNC/FTI00199
C-123456 XYS Contracting 31-Aug-18 CNC/SIV30964/CNC/SI-30964
Total due
答案1
这看起来像是 AWK 的工作,而不是 Excel 问题。您绝对应该添加有关输入数据以及您打算如何处理结果的更多详细信息。我们甚至不知道您希望输出是什么样子,因为您的问题是由其他人格式化的。您可以使用以下 AWK,可能对其进行调整以满足您未指定的需求:
/^$/ {
print
next
}
/Total due/ {
print "\t"$0
next
}
NR==2 {
a=$1"\t"$2" "$3;
print "Code\t\tName\t\t\tDate\t\tInvoice Number"
}
NR>2 {
print a"\t\t"$1"\t"$2
}
如何使用它:
我假设输入是名为 的文件的内容input.txt
。将脚本保存在名为 的文件中,script.awk
然后使用以下命令运行它awk -f script.awk input.txt
输出:
Code Name Date Invoice Number
C-123456 XYS Contracting 31-Mar-17 CNC/SIV45678/CNC/SI-45678
C-123456 XYS Contracting 21-Dec-17 CNC/SIV7894/CNC/SI-7894
C-123456 XYS Contracting 21-Dec-17 CNC/SIV12348/CNC/SI-12348
C-123456 XYS Contracting 31-May-18 CNC/SIV23458/CNC/SI-23458
C-123456 XYS Contracting 31-May-18 CNC/SIV3456/CNC/SI-3456
C-123456 XYS Contracting 30-Jun-18 CNC/SIV56789/CNC/SI-56789
C-123456 XYS Contracting 30-Jun-18 CNC/SIV1346/CNC/SI-1346
C-123456 XYS Contracting 14-Aug-18 CNC/FTIV00198/CNC/FTI00198
C-123456 XYS Contracting 14-Aug-18 CNC/FTIV00199/CNC/FTI00199
C-123456 XYS Contracting 31-Aug-18 CNC/SIV30964/CNC/SI-30964
Total due
笔记:
这可能是不是你想要什么。请添加更多详细信息并更改输出中的选项卡数量。