From: Steinar H. Gunderson Date: Sun, 13 Feb 2005 17:08:57 +0000 (+0000) Subject: Add the beginnings of a script for converting from the DDREurope result lists. X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=64bb65f65e37dbc157d3dd09b47de8a5da7d3690;hp=91d6894b6ea053730ed678d45f5cf9b4cf1962d8 Add the beginnings of a script for converting from the DDREurope result lists. --- diff --git a/parse/parse-ddreurope-tournament.pl b/parse/parse-ddreurope-tournament.pl new file mode 100644 index 0000000..ccee272 --- /dev/null +++ b/parse/parse-ddreurope-tournament.pl @@ -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 (/

\s* (.*?) \s* <\/h2>/x) { + $name = $1; + next; + } + if (/
Country: \s* (.*?) \s* +
Location: \s* (.*?) \s* +
Date: \s* (.*?) \s* +
Mix: \s* (.*?) \s* +
ScoringSystem: \s* (.*?) \s*
+ /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";