Add the beginnings of a script for converting from the DDREurope result lists.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sun, 13 Feb 2005 17:08:57 +0000 (17:08 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sun, 13 Feb 2005 17:08:57 +0000 (17:08 +0000)
parse/parse-ddreurope-tournament.pl [new file with mode: 0644]

diff --git a/parse/parse-ddreurope-tournament.pl b/parse/parse-ddreurope-tournament.pl
new file mode 100644 (file)
index 0000000..ccee272
--- /dev/null
@@ -0,0 +1,41 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use Date::Manip;
+
+# Parses tournament results from the DDR Europe result list
+
+my $season = shift;
+my $name;
+die "Missing season (give on command line)." if (!defined($season));
+
+print "begin;\n";
+
+while (<>) {
+       if (/<h2> \s* (.*?) \s* <\/h2>/x) {
+               $name = $1;
+               next;
+       }
+       if (/<br>Country: \s* (.*?) \s*
+             <br>Location: \s* (.*?) \s*
+             <br>Date: \s* (.*?) \s*
+             <br>Mix: \s* (.*?) \s*
+             <br>ScoringSystem: \s* (.*?) \s* <br>
+            /x) {
+               my ($country, $location, $date, $mix, $system) = ($1, $2, $3, $4, $5);
+               $mix =~ s/Euromix/EuroMix/;
+
+               print "INSERT INTO tournaments \n";
+               print "  (season, name, country, location, \"date\", machine, scoringsystem) VALUES (\n";
+               print "    (SELECT season FROM seasons WHERE name='$season'),\n";
+               print "    '$name',\n";
+               print "    (SELECT country FROM countries WHERE name='$country'),\n";
+               print "    '$location',\n";
+               printf "    '%s',\n", Date::Manip::UnixDate($date, '%Y-%m-%d');
+               print "    (SELECT machine FROM machines WHERE name='$mix'),\n";
+               print "    (SELECT scoringsystem FROM scoringsystems WHERE name='$system')\n";
+               print ");\n";
+       }
+}
+
+printf "commit;\n";