diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/latex4wp-it/dat2tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/latex4wp-it/dat2tex | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/latex4wp-it/dat2tex b/Master/texmf-dist/doc/latex/latex4wp-it/dat2tex new file mode 100644 index 00000000000..f7378a51973 --- /dev/null +++ b/Master/texmf-dist/doc/latex/latex4wp-it/dat2tex @@ -0,0 +1,28 @@ +#!/bin/sh + +# dat2tex: converts tabular data to a tabular environment + +if [ $# != 1 ]; then + echo "Usage: $0 <datafile>" + exit 1 +fi + +# is this a cvs file? +grep ";" $1 > /dev/null +if [ $? = 0 ]; then + AWK="awk -F;" +else + AWK=awk +fi + +# ok awk, make my day +$AWK '{if (1 == FNR) { \ + printf "\\begin\{tabular\}\{"; \ + for (i = 1; i <= NF; i++) {printf "l"}; \ + printf "\}\n" + } + for (i = 1; i < NF; i++) \ + {printf $i" & "} printf $NF" \\\\ \n"} \ + END {printf "\\end\{tabular\}\n"}' $1 + +# end of dat2tex |