File indexing completed on 2025-12-16 10:37:06
0001
0002 set -Euo pipefail
0003 trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
0004 IFS=$'\n\t'
0005
0006
0007 if [ $
0008 echo "Usage: "
0009 echo " $0 <file or url> [target hours = 2]"
0010 exit
0011 fi
0012
0013
0014
0015 FILE=${1}
0016 shift
0017
0018 TARGET=${1:-2}
0019 shift
0020
0021
0022 if [ -f "${FILE}" ] ; then
0023 echo "Using local file as input" 1>&2
0024 INPUT=(cat ${FILE})
0025 else
0026 echo "Using ${BASEURL}${FILE}${BASEJOB} as input" 1>&2
0027 INPUT=(curl ${BASEURL}${FILE}${BASEJOB})
0028 fi
0029
0030
0031 output=$(basename ${FILE} .csv)-$(date --iso-8601=minutes).csv
0032
0033
0034 "${INPUT[@]}" | grep -v ^curl | while IFS="," read file ext ntotal dt0 dt1 duf0 duf1 dur0 dur1 ; do
0035 if [[ "${file}" =~ csv$ ]] ; then
0036 ${0} ${TEMPLATE} ${TYPE} ${file} ${TARGET}
0037 else
0038 nevents=$(echo "scale=0; n=(3600*$TARGET-$dt0)/$dt1; if (n>$ntotal) print($ntotal) else print(n)" | bc -l)
0039 nchunks=$(echo "scale=0; n=$ntotal/$nevents+1; if (n==0) print(1) else print(n)" | bc -l)
0040 nevents=$(echo "scale=0; $ntotal/$nchunks" | bc -l)
0041 actualt=$(echo "scale=2; ($dt0+$nevents*$dt1)/3600" | bc -l)
0042 for ichunk in `seq 0 $((nchunks-1))` ; do
0043 echo "${file},${ext},${nevents},$(printf '%04d' $ichunk)"
0044 done
0045 fi
0046 done > ${output}
0047 echo "${output}"