This script converts a standard report in a excel-readable csv file. Standard = header (1 up to 3 lines) and details with | field separator. Specially the querys are standard.
Sorry, the comments are french.
Code:
#! /bin/ksh
# trexcel
#
# transformation d'un fichier edition baan en fichier excel
#
if [ $# -ge 2 ]
then
echo "le nom de fichier ne doit pas comporter de blanc"
echo "le fichier sera sous forme brute et non transforme excel"
echo "taper transmit\c"
read reponse
fi
awk -f /administration/awk-supent $1 > $HOME/temp
# suppression des blancs apres | (cadrage excel correct)
cat $HOME/temp | sed '1,$s/| /|/g' | sed '1,$s/;/\./g' | sed '1,$s/|/;/g' > $1
unix2dos $1 $1 2>/dev/null
rm $HOME/temp
chmod 666 $1
Code:
#! /bin/ksh
# awk-supent
#
# supression de toutes les lignes non significatives d'une edition
#
#
BEGIN {
ligne1="";
ligne2="";
ligne3="";
titre=0;
entete=0;
}
# stockage des entetes
{
pipes=index($0,"|");
if (pipes>0&&entete==0) {
if (titre==0) {
ligne1=$0; titre++; print $0}
else
{if (titre==1)
{ ligne2=$0; titre++; print $0}
else
{if (titre==2)
{ ligne3=$0; titre++; print $0}
}
}
}
# test une entete trouvee
if (pipes==0&&titre>0)
{entete=1}
#
# impression des lignes differentes des entetes
#
if (pipes>0&&$0!=ligne1&&$0!=ligne2&&$0!=ligne3)
{print $0}
}
device:
Code:
| Maintain Device Data |
|------------------------------------------------------------------------------|
| Device : E |
| Description : Excel (extraction vers) (div RIM) |
| Device Type : Rewrite file |
| Locale : |
|--Printer -----------------------------------------------------------|
| Driver : |
| Device Queue : |
| Paper Type : |
| Left Margin : Form Feed : |
|--File -----------------------------------------------------------|
| Driver : |
| Shell Command : |
| 4GL Program : ttstpconv |
| Argument : ASCII\/administration/trexcel %s |
| Path : |
| Change allowed : Yes |
| Page Length : 66 |