[pmwiki-users] Educational Uses of PM Wiki

Knut Alboldt pmwiki at alboldt.de
Thu Sep 6 14:48:27 CDT 2007


Hi David !

David Fionda schrieb:
> 3.)  Also, can I create a page in another application other than PM 
> WIki. 
yes, you have to create "simple" text pages which have the 
pmwiki-format. I did this using perl (any other script-language will do 
it) to parse a CSV-file into several pmwiki-pages
I read the csv-file (| as a separator), for each line I generate a new 
wiki-page (using perl, see sample script below, it fills my pmwiki with 
avideo-list), the wikipages are named using a time-stamp but you could 
also generate the pagename from the read data.
The wiki-text is one line, text-lines are separated by "%0a"

cheers

Knut




#! perl -w
#

use strict;
use English;
use Time::Local;

my $ctr = 0;

my ($sec,$min,$hours,$mday,$month,$year) = localtime();
my $datetimestamp = sprintf("%04d%02d%02d%02d%02d%02d", $year+1900, 
$month+1, $mday, $hours, $min, $sec);

print "Video8-Videoverzeichnis parsen\n";

open ( VERZ, "<videoverzeichnis-Video8.csv")
   or die "can't open videoverzeichnis.csv";

my $headline = <VERZ>;

while( defined( my $line = <VERZ> ) )
{
   chomp $line;
   my 
($cassno,$start,$len,$end,$title,$remarks,$regie,$jahr,$actors,$recorded,$playmode,$genre) 
= split /\|/, $line;

   $ctr++;
   # pagenamen aus titel generieren: "Video-Titel-"+unique timestamp
   my $pagename = "Video.Titel-" . $datetimestamp . $ctr;


   # TODO: split + join G: genre

   open ( WIKIPAGE, ">WIKIPAGES/$pagename")
     or die "can't open WIKIPAGES/$pagename for output";

   print WIKIPAGE "version=pmwiki-2.2.0-beta63 ordered=1 urlencoded=1
agent=perl-parser-script
author=KAL
charset=ISO-8859-1
name=$pagename
targets=
text=";

   print  WIKIPAGE "Titel:: $title%0a%0a";
   print  WIKIPAGE "Länge:: $len%0a%0a";
   print  WIKIPAGE "Schauspieler:: $actors%0a%0a";
   print  WIKIPAGE "Regie:: $regie%0a%0a";
   print  WIKIPAGE "Jahr:: $jahr%0a%0a";
   print  WIKIPAGE "Genre:: $genre%0a%0a";
   print  WIKIPAGE "aufgenommen am:: $recorded%0a%0a";
   print  WIKIPAGE "Playmode:: $playmode%0a%0a";
   print  WIKIPAGE "Video8:: $cassno $start-$end%0a%0a";
   print  WIKIPAGE "Bemerkungen:: $remarks%0a%0a";

   close WIKIPAGE;
}
close VERZ;

print "done.\n";



More information about the pmwiki-users mailing list