#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  sumstatsinstructions sumstats sumstats2 sumlines.awk
#   sumlines2.awk
# Wrapped by oliver@coate on Tue Nov 24 19:16:26 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'sumstatsinstructions' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sumstatsinstructions'\"
else
echo shar: Extracting \"'sumstatsinstructions'\" \(1679 characters\)
sed "s/^X//" >'sumstatsinstructions' <<'END_OF_FILE'
XThis is the instruction file for the sumstats package.
X
XFour other files are included as part of the package: the files "sumstats"
Xand "sumstats2" and the file "sumlines.awk" and "sumlines2.awk".  You must
Xmake two additional files before running: "templatelist" and a roster file
Xfor your team.
X
XHOW TO USE:
X
X1.  Make the files "sumstats" and "sumstats2" executable by typing "chmod
X755 sumstats".
X
X2.  Create a file called "templatelist" and put in it a list of all the
Xtemplates you want summed, i.e.,
X
Xbos47san47.11feb92
Xsan50sac50.16feb92
Xsan51lac51.17feb92
Xmia55san55.25feb92
Xgsw54san56.27feb92
Xden57san57.29feb92
Xsan58min57.03mar92
X
X3.  Create a roster file named with your three-letter team code.  The first
Xline in the roster file must be the three letter-team code.  Everything
Xelse must be in a stripped-down format of the standard NBASTATS roster, the
Ximportant thing being that only player names are included and *nothing* can
Xbe after the player name.  Below is the file "san" for "San Antonio".  Note
Xthat there is no space between the firstname, comma, and lastname of the
Xplayers.
X
Xsan
Xanderson,willie 
Xbardo,steve
Xcarr,antoine
Xcopa,tom
Xcummings,terry
Xelliott,sean
Xgreen,sidney
Xjohnson,vinnie
Xpressey,paul
Xrobinson,david
Xroyal,donald
Xstrickland,rod
Xsutton,greg
Xtucker,trent
X
X4.  Now, to run, simply type "sumstats tmc", where "tmc" is your particular
Xthree-letter team-code.  This will calculate the per game stats.  If you
Xwant to direct the output to a file, type "sumstats tmc > filename".
X
XThe script is slow, but it works.
X
X5.  If you want to calculate per 48 minute stats (*after* doing step #4),
Xthen type "sumstats2 tmc" or "sumstats2 tmc > filename2".
X
END_OF_FILE
if test 1679 -ne `wc -c <'sumstatsinstructions'`; then
    echo shar: \"'sumstatsinstructions'\" unpacked with wrong size!
fi
# end of 'sumstatsinstructions'
fi
if test -f 'sumstats' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sumstats'\"
else
echo shar: Extracting \"'sumstats'\" \(1503 characters\)
sed "s/^X//" >'sumstats' <<'END_OF_FILE'
X#!/bin/csh -f
X# script to calculate team stats
X# to use sumstats 
X
Xset teamname = $1
Xset templatelist = 'templatelist'
Xset namelist = $1
X
Xset awkfile = 'sumlines.awk'
Xset tmpfile = 'tmpfile'
Xset tmpfile2 = 'tmpfile2'
X
X# CALCULATE TEAM STATISTICS
X# 1.  Separate out player lines from the templates, store in $tmpfile
X
Xif (-r $tmpfile) rm $tmpfile
X
Xforeach name(`tail +2 $namelist`)
X	foreach template (`cat $templatelist`)
X		egrep $name $template >>! $tmpfile
X	end
Xend
X
Xecho "name   gms   m/g   p/g  r/g  a/g   fgp   3pp   ftp or/g  s/g to/g  b/g pf/g tc"
X
X# 2.  Sum up individual player totals and output to stdout
X
Xforeach name(`tail +2 $namelist | fgrep -v '$teamname '`)
X	awk -f $awkfile name=$name $tmpfile 
Xend
X
X# 3.  Add up team totals by re-doing step 2.
X
Xawk -f $awkfile name=team $tmpfile
X
X
X# CALCULATE OPPONENTS' STATISTICS (the hard part)
X
X# 1.  First generate player lines for all home games:
X
Xif (-r $tmpfile2) rm $tmpfile2
X
Xforeach template (`cat $templatelist | egrep {$teamname}'..\.'`)
X	awk 'BEGIN {FS = ","} /GAME/ {dothis = 0} /END/ {dothis = 0} \
X		dothis != 0 { print $0 } /VISITOR/ { dothis = 1}' \
X		$template >>! $tmpfile2
Xend
X
X# 2.  Now for all away games:
X
Xforeach template (`cat $templatelist | egrep -v \[0-9\]{$teamname}`)
X	awk 'BEGIN {FS = ","} /GAME/ {dothis = 0} /END/ {dothis = 0} \
X		dothis != 0 { print $0 } /HOME/ { dothis = 1}' \
X		$template >> $tmpfile2
Xend
X
X# 3. Now tromp through the whole file as with total team stats
X
Xawk -f $awkfile name=opponents $tmpfile2
X
X
END_OF_FILE
if test 1503 -ne `wc -c <'sumstats'`; then
    echo shar: \"'sumstats'\" unpacked with wrong size!
fi
chmod +x 'sumstats'
# end of 'sumstats'
fi
if test -f 'sumstats2' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sumstats2'\"
else
echo shar: Extracting \"'sumstats2'\" \(418 characters\)
sed "s/^X//" >'sumstats2' <<'END_OF_FILE'
X#!/bin/csh -f
X
X#script to calculate per 48 minute stats on previously created files
X
Xset teamname = $1
Xset namelist = $teamname
X
Xset awkfile = 'sumlines2.awk'
Xset tmpfile = 'tmpfile'
Xset tmpfile2 = 'tmpfile2'
X
Xecho "Per 48 minutes"
Xecho "name      pts   reb   ast   fga   3pa   fta    or    pf    st    to    bk"
X 
Xforeach name(`tail +2 $namelist | fgrep -v '$teamname '`)
X	awk -f $awkfile name=$name $tmpfile 
Xend
X
X
X
END_OF_FILE
if test 418 -ne `wc -c <'sumstats2'`; then
    echo shar: \"'sumstats2'\" unpacked with wrong size!
fi
chmod +x 'sumstats2'
# end of 'sumstats2'
fi
if test -f 'sumlines.awk' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sumlines.awk'\"
else
echo shar: Extracting \"'sumlines.awk'\" \(972 characters\)
sed "s/^X//" >'sumlines.awk' <<'END_OF_FILE'
XBEGIN {FS = ","}
X	{ test = $1 FS $2
X	   if ((test == name) || (name == "team") || (name == "opponents"))
X		{	
X			lastname = $1
X			gms += 1
X			min += $3
X			fga += $4
X			fgm += $5
X			tpa += $6
X			tpm += $7
X			fta += $8
X			ftm += $9
X			or += $10
X			tr += $11
X			ast += $12
X			pf += $13
X			st += $14
X			to += $15
X			bk += $16
X			tc += $17 
X			ff += $18
X		}
X	}
XEND {	if (gms == 0) exit
X
X	if ((name == "team") || (name == "opponents")) 
X		gms = int(min/240)
X	else
X		name = lastname
X
X	tp = fgm*2 + tpm +ftm
X	ppg = tp/gms
X	mpg = min/gms
X	if (fga != 0) 
X		fgp = fgm/fga
X	else
X		fgp = 0
X	if (tpa != 0) 
X		tpp = tpm/tpa
X	else 
X		tpp = 0
X	if (fta != 0) 
X		ftp = ftm/fta
X	else
X		ftp = 0
X	orpg = or/gms
X	trpg = tr/gms
X	apg = ast/gms
X	pfpg = pf/gms
X	stpg = st/gms
X	topg = to/gms
X	bkpg = bk/gms
X	printf ("%-7.7s %2.0f %5.1f %5.1f %4.1f %4.1f %5.3f %5.3f %5.3f %4.1f %4.1f %4.1f %4.1f %4.1f %2.0f \n", name, gms, mpg, ppg, trpg, apg, fgp, tpp, ftp, orpg, stpg, topg, bkpg, pfpg, tc)
X	}
X
X
X
END_OF_FILE
if test 972 -ne `wc -c <'sumlines.awk'`; then
    echo shar: \"'sumlines.awk'\" unpacked with wrong size!
fi
# end of 'sumlines.awk'
fi
if test -f 'sumlines2.awk' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sumlines2.awk'\"
else
echo shar: Extracting \"'sumlines2.awk'\" \(870 characters\)
sed "s/^X//" >'sumlines2.awk' <<'END_OF_FILE'
XBEGIN {FS = ","}
X	{ test = $1 FS $2
X	   if ((test == name) || (name == "team") || (name == "opponents"))
X		{	
X			lastname = $1
X			gms += 1
X			min += $3
X			fga += $4
X			fgm += $5
X			tpa += $6
X			tpm += $7
X			fta += $8
X			ftm += $9
X			or += $10
X			tr += $11
X			ast += $12
X			pf += $13
X			st += $14
X			to += $15
X			bk += $16
X			tc += $17 
X			ff += $18
X		}
X	}
XEND {	if (gms == 0) exit
X
X	if ((name == "team") || (name == "opponents")) 
X		gms = int(min/240)
X	else
X		name = lastname
X
X	fac=48/min
X	tp = fgm*2 + tpm +ftm
X	tp48 = tp*fac
X	fga48 = fga *fac
X	tpa48 = tpa * fac
X	fta48 = fta * fac
X	or48 = or * fac
X	tr48 = tr * fac
X	a48 = ast * fac
X	pf48 = pf * fac
X	st48 = st * fac
X	to48 = to * fac
X	bk48 = bk * fac
X	printf ("%-7.7s %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f \n", name, tp48, tr48, a48, fga48, tpa48, fta48, or48, pf48, st48, to48, bk48)
X	}
X
X
X
END_OF_FILE
if test 870 -ne `wc -c <'sumlines2.awk'`; then
    echo shar: \"'sumlines2.awk'\" unpacked with wrong size!
fi
# end of 'sumlines2.awk'
fi
echo shar: End of shell archive.
exit 0
