blob: f7378a519739088fc636574ab712dfe54e49db8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
|