aboutsummaryrefslogtreecommitdiffstats
path: root/test/fpat9.awk
blob: 06142b857dbc5d306eaf2c4e2fb65db9553dc729 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /bin/gawk  -f

# Modified version of program from Arthur Schwarz <home@slipbits.com>.

BEGIN {                                         # program constants
         FPAT         = "([^,]*)|(\"([^\"]|\"\")+\")" # CSV field separator
         print "FPAT = ", FPAT;
}
{
        print "------------------------------------------------\n"
        print $0;
        printf("%3d:   \n", NF);
        for (i = 1; i <= NF; i++) {
           if (substr($i, 1, 1) == "\"") {
              len = length($i)		# BUG FIX, was length($1)
              $i = substr($i, 2, len - 2);
	     gsub(/""/, "\"", $i)	# embedded "" --> "
           }
           printf("      <%d: %s>\n", i, $i);
        }
        print " ";
}