回复 1# zhengwei007
第3方工具gawk( http://bcn.bathome.net/tool/4.1.0/gawk.exe )的实现方式如下:- gawk -v"FS=\042" "BEGIN{print \"ingredientID\tcount\tingredientID\tcount\tingredientID\tcount\tingredientID\tcount\tingredientID\tcount\tproductionID\tcount\"}/^[\t ]*<item>$/,/^[\t ]*<\/item>$/{if(/^[\t ]*<ingredient count=.+id=.+>$/){A[++i]=$4;B[i]=$2}if(/^[\t ]*<production count=.+id=.+>$/){A[6]=$4;B[6]=$2;C=A[1]\"\t\"B[1];for(i=2;i<7;i++)C=C\"\t\"A[i]\"\t\"B[i];print C;delete A;delete B;i=0}}" *.xml>sour.csv
复制代码
|