#!/usr/local/bin/perl #format is uid\t[name]\tscore\t[comment] #name and comment can be blank, \t separators still required #name any format, space within col okay require "/w/class.01/cs/cs131/cs131ta/risc/grades/column_names"; $col=convert_col (shift @ARGV); $scale=(shift @ARGV || 1); unless ($col) { die "Need at least 1 params the column number\n"; } unless ($scale =~ m:\d+(\.\d+)?:) { die "Scale must be a positive number, eg 0.5, 4, 10.2\n"; } &readgrades; shift @grades; #ditch fields line pop @grades; #ditch averages line foreach $student (@grades) { chomp $student; @sgrades=split (/,/, $student); if ($sgrades[$columns{"sid"}] =~ m:^\d{9}$:) { $score=$scale*$sgrades[$col]; $line=$sgrades[$columns{"sid"}] . "\t" . $sgrades[$columns{"lname"}] . "\t" . $sgrades[$columns{"fname"}] ."\t". $score . "\t\n"; if ($sgrades[$columns{"lecture"}] =~ m:1:) {push @new_1, $line;} else {push @new_2, $line;} } else { print "Can't upload for ", $sgrades[$columns{"seas"}], ".\n"; push @nouid, $sgrades[$columns{"seas"}]; } } open (GRADES, ">$home/grades/grades-$col-1.csv") or die "Can't write grades-$col-1.csv\n $!"; print GRADES @new_1; close (GRADES); open (GRADES, ">$home/grades/grades-$col-2.csv") or die "Can't write grades-$col-2.csv\n $!"; print GRADES @new_2; close (GRADES); if (@nouid) { open (LOG, ">log-$col.log") or exit; print LOG "The following seas accounts have not given us UIDs:\n"; print LOG "@nouid\n"; close (LOG); }