5 # this tool manipulates fixed length cch tax files by comparing the
6 # update files in the $update_dir to the initial install files
9 # it produces .DOIT files in $update_dir which are suitable for
10 # syncing a database initialzed with the files in $init_dir to
11 # the state represented by the files in $update_dir
13 # how one acquires update files from cch that overlap with initial
14 # full install remains a mystery
16 my $init_dir = "cchinit/";
17 my $update_dir = "cchupdate/";
19 foreach my $file (qw (CODE DETAIL PLUS4 GEOCODE TXMATRIX ZIP)) {
20 my $tfile = $update_dir. $file. "T";
21 $tfile = $update_dir. "TXMATRIT" if $tfile =~ /TXMATRIXT$/;
22 open FILE, "$tfile.TXT" or die "Can't open $tfile.TXT\n";
23 open INSERT, ">$tfile.INS" or die "Can't open $tfile.INS\n";
24 open DELETE, ">$tfile.DEL" or die "Can't open $tfile.DEL\n";
27 print INSERT "$_\n" if s/I$//;
28 print DELETE "$_\n" if s/D$//;
33 system "sort $tfile.INS > $tfile.INSSORT";
34 system "sort $tfile.DEL > $tfile.DELSORT";
35 system "sort $init_dir$file.txt > $tfile.ORGINSSORT";
36 system "comm -12 $tfile.INSSORT $tfile.ORGINSSORT > $tfile.PREINS";
37 system "comm -23 $tfile.INSSORT $tfile.ORGINSSORT > $tfile.2BEINS";
38 system "comm -23 $tfile.DELSORT $tfile.ORGINSSORT > $tfile.PREDEL";
39 system "comm -12 $tfile.DELSORT $tfile.ORGINSSORT > $tfile.2BEDEL";
42 foreach my $file (qw (CODET DETAILT PLUS4T GEOCODET TXMATRIT ZIPT)) {
43 my $tfile = $update_dir. $file;
44 $tfile = "TXMATRIT" if $tfile eq "TXMATRIXT";
45 open INSERT, "$tfile.2BEINS" or die "Can't open $tfile.2BEINS\n";
46 open DELETE, "$tfile.2BEDEL" or die "Can't open $tfile.2BEDEL\n";
47 open FILE, ">$tfile.DOIT" or die "Can't open $tfile.DOIT\n";