/
relatorio.sh
65 lines (62 loc) · 2.31 KB
/
relatorio.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
## Script to create PDF from HTML
empresa=$1
variavel='Valores'
echo "<!DOCTYPE html>
<html lang='pt-br'>
<head>
<meta charset='utf-8'/>
<link rel='stylesheet' type='text/css' href='style.css'>
<title>Relatório</title>
</head>
<body>" > relatorio.html
echo " <h1><br><br><br><img src='helpers/logo.png' width='300'><br><br><br><br><br></h1>" >> relatorio.html
echo " <h1>Estudo - "$empresa"</h1>" >> relatorio.html
echo " <h3 class='titulo'>Tópico</h3>" >> relatorio.html
echo " <p>Esse relatório é sobre a empresa " $empresa":</p>" >> relatorio.html
echo " <ul>" >> relatorio.html
echo " <li>item 1</li>" >> relatorio.html
echo " <li>item 2</li>" >> relatorio.html
echo " <li>item 3</li>" >> relatorio.html
echo " </ul>" >> relatorio.html
echo " <p>Veja a tabela a seguir:</p>" >> relatorio.html
# Convert CSV data to HTML
print_header=false
nt=1
for file in `ls output/*/Coeficientes.csv`; do
lugar=$(echo $file | awk -F'/' '{print $3}' | awk -F'_' '{print $1}')
tipo=$(echo $file | awk -F'/' '{print $2}' | tr [a-z] [A-Z])
echo "<div class='tabela'>" >> relatorio.html
echo "<table>" >> relatorio.html
while read INPUT ; do
if $print_header;then
echo "<tr><th>$INPUT" | sed -e 's/:[^,]*\(,\|$\)/<\/th><th>/g' >> relatorio.html
print_header=false
fi
echo "<tr><td>${INPUT//,/</td><td>}</td></tr>" >> relatorio.html
done < $file ;
echo "</table>" >> relatorio.html
echo "</div>" >> relatorio.html
echo "<p class='subtabela'>Tabela "$nt" - números aleatórios entre 0 e 1</p>" >> relatorio.html
nt=$(($nt+1))
done
# End of table printing
echo " <p>Aqui vai um texto bem supimpa.</p>" >> relatorio.html
echo " <h3 class='titulo'>Outro tópico</h3>" >> relatorio.html
echo " <p>Mais um texto prafrentex.</p>" >> relatorio.html
nf=1
# List of Figures
for file in `ls output/*/*.png`; do
lugar=$(echo $file | awk -F'/' '{print $3}' | awk -F'_' '{print $1}')
tipo=$(echo $file | awk -F'/' '{print $2}')
regressores=$(echo $file | awk -F'/' '{print $3}' | awk -F'_' '{print $2}' | awk -F'.' '{print $1}')
# Print figure
echo " <figure>
<img src='"$file"'>
<figcaption>Fig. "$nf" - Valores em" $lugar": números aleatórios</figcaption>
</figure>" >> relatorio.html
nf=$(($nf+1))
done
echo " </body>
</html>" >> relatorio.html
/usr/bin/wkhtmltopdf -B 20 -L 20 -R 20 -T 20 relatorio.html relatorio.pdf