ihmq clientes h00^ h09^ > rutas
awk -F";" ' $1+0!=0 {clien=sprintf("%.5d",$1) }
{
	for (i=6;i<20;i++) if($i+0) ped[sprintf("%.2d",i-5)"^"clien]=ped[sprintf("%.2d",i-5)"^"clien]""$4"^"$5"^"$i+0"^"
}
END {
	for (i in ped) print i"^"ped[i]


} ' TRJUL.csv TRJULV.csv| sort | 
awk -F^ ' FILENAME==ARGV[1] { ruta[$1]=substr($2,1,2) ; next }
{

fil=sprintf("/tmp/PED%.4d",FNR)

printf "H01%.5d\n",FNR >fil
printf "H022022-07-%s\n",$1 >fil
printf "H03%s\n",$2 >fil
printf "H04%s\n",ruta[$2] >fil
printf "H06%s\n","00" >fil
z=0
for (i=3;i<NF;i+=3)
{
k=0
printf "D%.2d%.2d%s\n",z,k++,$i >fil
printf "D%.2d%.2d%s\n",z,k++,$i >fil
printf "D%.2d%.2d%s\n",z,k++,$(i+1) >fil
printf "D%.2d%.2d%s\n",z,k++,$(i+2) >fil
printf "D%.2d%.2d%s\n",z,k++,$(i+1)*$(i+2) >fil
z++
}
print " " >fil
} ' rutas -
cd ..
echo -n "    0      0" >data/pedidos/INFO
>data/pedidos/H
for i in /tmp/PED*
do
echo $i
ihmu pedidos $i -N1
rm $i
done




