From 38c64f45d620a2d8efda13e6225f3ef5e8463eaf Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 7 Nov 2005 16:14:37 +0100 Subject: [PATCH] [svn r7287] added a script (copied from Martin's 204 one with trivial modifications) --- smkridge/234/tablize-qms.pl | 198 ++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 smkridge/234/tablize-qms.pl diff --git a/smkridge/234/tablize-qms.pl b/smkridge/234/tablize-qms.pl new file mode 100644 index 000000000..e3705442a --- /dev/null +++ b/smkridge/234/tablize-qms.pl @@ -0,0 +1,198 @@ +#!/usr/bin/perl -w +use strict; +use Getopt::Long; + +((my $progname = $0) =~ s/^.*(\/|\\)//ig); # basename $0 + +# Parse options +my $no_verbose_progress = 0; +my $usage = 0; +GetOptions('quiet' => \$no_verbose_progress, # be quiet + 'help|?' => \$usage # help! + ); + +# Print usage +if ($usage) { + usage(); +} + +unless ($ARGV[0]) { + print "Specify a CSV file name as the program's argument (e.g. qm.csv)\n"; + usage(); +} + +open (CSV, "< $ARGV[0]"); + +# Start writing table file, and write table header +open TABLE, "> qm.html" or die $!; +print TABLE << "END"; + + + + + + + +1623/234 Question Mark List + + + + +

Hauchhöhle Question Mark list

+
+Extant QM's + -- Finished QM's + -- 234 index +
+
+

Conventions

+ +

For question mark list conventions, see here.

+ +

Area codes

+ + + + + + + + + + +
EntEntrance passages
LHLeft-Hand Series
TrunkMain trunk from Doesn't Go Rift to Cess Pot
MeaslesMeasles Inlet and Cascade Chamber area
SSSweet Sight
PiePie Series
UnderUnderhand Passage
Wowoland2005 Wowoland / Monster's Lair level
+ +

Question Marks

+ +END + +; # starting to read in csv file, eat header line + +my ($number, $grade, $area, $desc, $ref, $station, $completion); +my $incomplete=""; +my $complete=""; +my $templine; +my $colon; +my @stationbits; +print "Progress: *"; + +my $thisyear = -1; +my $qmyear; + +# While loop which reads in each line of csv file +while () { + chomp; + # Split single line into all the fields + ($number, $grade, $area, $desc, $ref, $station, $completion) = &parse_csv($_); + if ($completion and $ref) + { + print "\n?? Backlink for completed $number\n"; + } + $qmyear = substr($number, 1, 4); + if($qmyear != $thisyear) + { + $complete = "$complete\n

$qmyear

\n"; + $incomplete = "$incomplete\n

$qmyear

\n"; + $thisyear = $qmyear; + } + # Last field of CSV file can have weird form-feeds etc. Kill them + $completion =~ s/\r//; + + # Construct XHTML line + if ($ref) { + $templine = "
$number"; + } else { + $templine = "
$number"; + } + + $templine = "$templine $grade
"; + + $colon = ""; + if ($completion || $desc) { + $colon = ": "; + } + + @stationbits = split(/\./, $station); + if ($#stationbits > 0) + { + $station = "$stationbits[-2].$stationbits[-1]"; + } + if ($station) { + if ($area) { + $templine = "$templine$area, near $station$colon"; + } else { + $templine = "${templine}Near $station$colon"; + } + } elsif ($area) { + $templine = "$templine$area$colon" + } + + if ($completion) { + $complete = "$complete$templine$completion
\n"; + } else { + $incomplete = "$incomplete$templine$desc\n"; + } + + print "*"; +} + +print TABLE << "END"; +

Extant QMs

+ +
+$incomplete +
+ +

Completed QMs

+ +
+$complete +
+ +
+ + + +END + +close TABLE; +print "\nInformation: Done\n"; + +# Parse the CSV file +sub parse_csv { + my $line = $_[0]; + my @parsedline = (); + my $field = ''; + + while ($line =~ m{ \G(?:^|,) + (?: "((?> [^"]*) (?> "" [^"]*)*)" | ([^",]*)) }gx) { + if ($2) { + $field = $2; + } elsif ($1) { + $field = $1; + $field =~ s/""/"/g; + } else { + $field = ''; + } + + push(@parsedline, $field); + } + + return(@parsedline); +} + +# Usage +sub usage { + print << "EOF"; +USAGE: $progname [-options] + -q, --quiet Be quiet about progress + -h, --help Show this message +EOF + exit(0); +}