| 1 |
#! /bin/gawk -f |
| 2 |
|
| 3 |
# Modified version of program from Arthur Schwarz <[email protected]>. |
| 4 |
|
| 5 |
BEGIN { # program constants |
| 6 |
FPAT = "([^,]*)|(\"([^\"]|\"\")+\")" # CSV field separator |
| 7 |
print "FPAT = ", FPAT; |
| 8 |
} |
| 9 |
{ |
| 10 |
print "------------------------------------------------\n" |
| 11 |
print $0; |
| 12 |
printf("%3d: \n", NF); |
| 13 |
for (i = 1; i <= NF; i++) { |
| 14 |
if (substr($i, 1, 1) == "\"") { |
| 15 |
len = length($i) # BUG FIX, was length($1) |
| 16 |
$i = substr($i, 2, len - 2); |
| 17 |
gsub(/""/, "\"", $i) # embedded "" --> " |
| 18 |
} |
| 19 |
printf(" <%d: %s>\n", i, $i); |
| 20 |
} |
| 21 |
print " "; |
| 22 |
} |