MEDIAWIKI
Ir para navegação
Ir para pesquisar
Convert CSV to wikitable using BASH
DOC=plan.csv
echo Number of columns=$(cat $DOC | tr '\n' ' ' | tr '\r' '\n' | head -n 1 | tr ';' '\n' | wc -l )
echo "{|class=wikitable"
coproc stdbuf -o0 sed "s/^ *//g"
cat $DOC | \
tr '\n' ' ' | \
tr '\r' '\n' > tmp
while IFS=\; read c{1..6}
do
echo -e "|"$c{1..6}"\n" "|-" >&${COPROC[1]}
read -u ${COPROC[0]} msg
echo $msg
done < tmp
kill $COPROC_PID