#!/usr/bin/perl #use strict; use warnings; #Load up zipcode lookup hash for entity, antenna location open(ERR, ">err_ext_entity.txt"); open(ZIP, "./fcc/zipcodes.csv"); my $count = 0; my $total = 0; my @ziplist; my @citylist; my $city; my $state; while() { chomp; ($zip,$city,$state) = split /,/, $_; push(@ziplist, $zip); push(@citylist, $city); } close(ZIP); my %zipcodes; my %cities; @zipcodes{@ziplist}=(); @cities{@citylist}=(); my @files= qw(./fcc/l_LMcom/EN.dat ./fcc/l_LMpriv/EN.dat ./fcc/l_LMbcast/EN.dat); my @fields; my $zip2; my %callsign; open(OUT, ">./extract/EN.dat"); foreach $filename (@files){ open (EN, "<$filename") || die "Cannot open $filename for reading: $!\n"; while(){ @fields = split /\|/, $_; $zip2 = substr $fields[18],0,5; if (scalar(@fields) != 27){ print ERR "$filename has $number (27) fields $_\n"; next; } if (exists $zipcodes{$zip2}) { $count++; $callsign{$fields[4]}++; print OUT; push(@entity,$_); } } close EN; print "$filename has $count records\n"; $total+=$count; $count = 0; } print "all EN.dat $total records\n\n"; close OUT; @files= qw(./fcc/l_LMcom/LO.dat ./fcc/l_LMpriv/LO.dat ./fcc/l_LMbcast/LO.dat); open(OUT, ">./extract/LO.dat"); $total = 0; my @county = qw(BEXAR COMAL HAYS BLANCO GUADALUPE KENDALL); my %counties; @counties{@county}=(); foreach $filename (@files){ open (LO, "<$filename") || die "Cannot open $filename for reading: $!\n"; while(){ @fields = split /\|/, $_; if (scalar(@fields) != 51){ print ERR "$filename has $number (51) fields $_\n"; next; } if (exists $callsign{$fields[4]} || (exists $counties{$fields[13]} && $fields[14] eq "TX")){ $count++; print OUT; push(@location,$_); } } close LO; print "$filename has $count records\n"; $total+=$count; $count = 0; } print "all LO.dat $total records\n\n"; close OUT; @files= qw(./fcc/l_LMcom/FR.dat ./fcc/l_LMpriv/FR.dat ./fcc/l_LMbcast/FR.dat); open(OUT, ">./extract/FR.dat"); $total = 0; foreach $filename (@files){ open (FR, "<$filename") || die "Cannot open $filename for reading: $!\n"; while(){ @fields = split /\|/, $_; if (scalar(@fields) != 29){ print ERR "$filename has $number (29) fields $_\n"; next; } if (exists $callsign{$fields[4]}){ $count++; print OUT; push(@frequency,$_); } } close FR; print "$filename has $count records\n"; $total+=$count; $count = 0; } print "all FR.dat $total records\n\n"; close OUT; @files= qw(./fcc/l_LMcom/HD.dat ./fcc/l_LMpriv/HD.dat ./fcc/l_LMbcast/HD.dat); open(OUT, ">./extract/HD.dat"); $total = 0; foreach $filename (@files){ open (HD, "<$filename") || die "Cannot open $filename for reading: $!\n"; while(){ @fields = split /\|/, $_; if (scalar(@fields) != 50){ print ERR "$filename has $number (50) fields $_\n"; next; } if (exists $callsign{$fields[4]} && $fields[5] eq "A"){ $count++; print OUT; push(@header,$_); } } close HD; print "$filename has $count records\n"; $total+=$count; $count = 0; } print "all HD.dat $total records\n\n"; close OUT; $count = 0; close(ERR);