aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbanner2csv.pl41
1 files changed, 29 insertions, 12 deletions
diff --git a/banner2csv.pl b/banner2csv.pl
index 7c5ef7b..31dccc1 100755
--- a/banner2csv.pl
+++ b/banner2csv.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# FILE: "/home/evmik/src/my_src/GradeBook/banner2csv.pl"
-# LAST MODIFICATION: "Fri, 29 Aug 2014 17:36:54 -0400 (evmik)"
+# LAST MODIFICATION: "Wed, 21 Jan 2015 16:06:08 -0500 (evmik)"
# (C) 2012 by Eugeniy Mikhailov, <evgmik@gmail.com>
#use HTML::Entities;
@@ -13,14 +13,14 @@ use Data::Dumper;
if ( @ARGV < 1 )
{
- print "Converts a WM banner summary list to csv file with students info\n";
- print "\n";
- print "Usage:\n";
- print " " . $0 . " banner_html_file_to_parse\n";
- print "\n";
- print "Example:\n";
- print " " . $0 . " banner_class_summary_list.html\n";
- die;
+print "Converts a WM banner summary list to csv file with students info\n";
+print "\n";
+print "Usage:\n";
+print " " . $0 . " banner_html_file_to_parse\n";
+print "\n";
+print "Example:\n";
+print " " . $0 . " banner_class_summary_list.html\n";
+die;
}
my $html_file = shift;
@@ -29,6 +29,26 @@ open (F_HTML, "<", $html_file) or die "Failed to read file $html_file : $!";
my @fcontent = <F_HTML>;
$html_string=join('', @fcontent);
+# lets find CRN, i.e. section number
+my $flag_crn_located = 0;
+foreach $ln (@fcontent) {
+if ($flag_crn_located == 1) {
+ $crn_str = $ln;
+ last;
+}
+if ($ln =~ /CRN:/) {
+ $flag_crn_located = 1;
+}
+}
+#print "crn string ".$crn_str;
+my $section = "unknown";
+if ( $crn_str =~ m{>(\d+)<} ) {
+ $section = $1;
+} else {
+ $section = "unknown";
+}
+#print "section: ".$section."\n";
+
# this look for the table based on its headers
my $te = HTML::TableExtract->new(
@@ -134,9 +154,6 @@ foreach $row ($te->rows) {
$email = $href;
$email =~ s/mailto://;
- # section
- $section = "unknown";
-
print join(',', $sid, $fname, $lname, $section, $email);
print "\n";
}