I've created a script for you:
#!/bin/bash
# save field seperator to variable
OLDIFS=$IFS
# set field seperator for the csv-file
IFS=,
# Read line after line from the csv-file. In every line, the fields are seperated by the seperator defined in IFS. If you want to use , in your headings, chose another seperator like # for example. You have to change IFS=, to IFS=# and in the next line while IFS=, read ... to while IFS=# read ...
while IFS=, read -r FILENAME TITLE HEADING1 HEADING2 HEADING3 HEADING4
do
# create subdirectory if it not exists
mkdir -p ./import
WIKIPAGE="./import/$FILENAME.txt"
echo "====== $TITLE ======" > $WIKIPAGE
echo >> $WIKIPAGE
echo "===== $HEADING1 =====" >> $WIKIPAGE
echo >> $WIKIPAGE
echo "===== $HEADING2 =====" >> $WIKIPAGE
echo >> $WIKIPAGE
echo "===== $HEADING3 =====" >> $WIKIPAGE
echo >> $WIKIPAGE
echo "===== $HEADING4 =====" >> $WIKIPAGE
echo "Page $TITLE created!"
done < import.csv
# restore field seperator
IFS=$OLDIFS
You have to put your csv in the same directory as this script. The csv could have this content:
animals,Animals,Cat,Dog,Horse,Snake
fruits,Fruits,Apple,Banana,Orange,Pineapple
capitals,Capitals,London,Paris,Berlin,Washington
After starting the script (don't forget to make it executable, for example with
chmod +x import.sh[/m] (where import.sh is the filename of the script), you will get this files in the subdirectory [m]import:
File animals.txt
====== Animals ======
===== Cat =====
===== Dog =====
===== Horse =====
===== Snake =====
File capitals.txt
====== Capitals ======
===== London =====
===== Paris =====
===== Berlin =====
===== Washington =====
File fruits.txt
====== Fruits ======
===== Apple =====
===== Banana =====
===== Orange =====
===== Pineapple =====
I've put the script, the csv and the generated pages in a zip-file in the attachement.
I really love DokuWiki for its simplicity in storing contents!
Greetings,
Christoph
EDIT: I forgot to say: file names can't have spaces, uppercase letters or any other special chars in it, otherwise DokuWiki won't recognize them!