回复 1# zhengwei007
将以下文本以ANSI编码格式保存为modi_rec_csv.awk,下载gawk( http://bcn.bathome.net/tool/4.1.0/gawk.exe )后执行 gawk -fmodi_rec_csv.awk rec.csv>sour.csv即可:- BEGIN {
- OFS = "\t"
- }
- {
- A = $1
- B = gensub(/^(.+)=.+$/, "\\1", "1", $2)
- C = gensub(/^[^]\[\]]+(({\[[^]\[\]]+\];[0-9]+;[0-9]+;[0-9]+(\.[0-9]+)?};?)+)[^]\[\]]+$/, "\\1", "1", $2)
- n = patsplit(C, c, /[^\[\];\{\}]+/)
- for (i = 1; i <= n; i += 4) {
- print A, B, c[i], c[i + 1], c[i + 2], c[i + 3] OFS
- }
- B = gensub(/^(.+)=.+$/, "\\1", "1", $3)
- n = patsplit($3, c, /{(({\[[^]\[\]]+\];[0-9]+;[0-9]+;[0-9]+(\.[0-9]+)?};?)+)};[0-9]+(\.[0-9]+)?/)
- for (i = 1; i <= n; i++) {
- m = patsplit(c[i], d, /[^\[\];\{\}]+/)
- for (j = 1; j < m; j += 4) {
- print A, B, d[j], d[j + 1], d[j + 2], d[j + 3], d[m]
- }
- }
- }
复制代码
|