Guest User

Untitled

a guest
Oct 29th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.52 KB | None | 0 0
  1. #!/usr/bin/awk -f
  2. BEGIN {
  3.   FS = "|"
  4. }
  5.  
  6. FNR == NR {
  7.   chans[++ch] = $0;
  8. }
  9.  
  10. {
  11.   fips[$1];
  12.   coun[$1] = $7;
  13.   stat[$1] = $8;
  14.   own[$1,$4] = ((c[$1,$4]++) ? own[$1,$4] " & " $2" ("$6")" : $2" ("$6")");
  15. }
  16.  
  17. END {
  18.   printf("%s\t%s\t%s\t", "COUNTY", "STATE", "FIPS");
  19.   for (i=1; i<=ch; i++) {
  20.     printf("%s\t", chans[i]);
  21.   }
  22.   printf("\n");
  23.  
  24.   for (f in fips) {
  25.     printf("%s\t%s\t%s\t", coun[f], stat[f],f);
  26.     for (i=1; i<=ch; i++) {
  27.       printf("%s\t", own[f,chans[i]]);
  28.     }
  29.     printf("\n");
  30.   }
  31. }
Add Comment
Please, Sign In to add comment