#!/usr/bin/perl

my @vars = qw(dept course section scheduleCode courseTitle monday tuesday wednesday thursday friday start stop printTime buildingAbbr room courseCapacity currentEnrollment professorName publicURL);

print "data = {\n";

my $lastDept = "";
my $lastCourse = "";

while (<>) {
	chomp; s/"//g;

	($dept,$course,$section,$scheduleCode,$courseTitle,$monday,$tuesday,$wednesday,$thursday,$friday,$start,$stop,$printTime,$buildingAbbr,$room,$courseCapacity,$currentEnrollment,$professorName,$publicURL) = split /,/;

	$dept =~ s/ *$//g;
	$course =~ s/ *$//g;

	if ($dept ne $lastDept) {
		print "] },\n" if $lastDept ne "";
		print "\"$dept\" : {\n";
		$lastCourse = "";
	}

	if ($course ne $lastCourse) {
		print "],\n" if $lastCourse ne "";
		print "\"$course\" : [\n";
	}

	print "{ ";
	foreach $var (@vars) {
		my $data = $$var;
		$data =~ s/ *$//g;
		$data =~ s/\\//g;
		print "$var: \"$data\", ";
	}
	print " },\n";

	$lastDept = $dept;
	$lastCourse = $course;
}

print "] } }\n";
