#!/usr/bin/perl -w
#input the grades file from coursework
#obtain grades.crowd that is acceptable for crowd mark
#
#call your file "grades.csv" or else use ">crowdify your_file_name"
#
#Author: Wojciech Wieczorek

use strict;

my $file = shift;
$file = "grades.csv" unless $file;

open(IN, "<$file") || die "Couldn't open $file: $!\n";
open(OUT, ">grades.crowd") || die "Couldn't open grades.crowd file: $!\n";

print OUT "Name,Email,ID\n";
while ( my $this = <IN>){
    chomp $this;
next unless $this =~m!^([^,]*),"([^",]*),\s*([^",]*)",(\d*),!;
print OUT "$3 $2,$1\@stanford.edu,$4\n";
} #while
close(IN);
close(OUT);
