diff --git a/steps/report.sh b/steps/report.sh index 27b59968..a5f71ca6 100755 --- a/steps/report.sh +++ b/steps/report.sh @@ -76,40 +76,30 @@ latex_escape() { printf "\\hline\n" } >> "${aggregation_table}" -files=("${TARGET}/data/aggregation/*.csv") - -# shellcheck disable=SC2128 -# I disabled it, because unwrapping array and take first elem is exactly what i need in this script -if compgen -G "${files}" > /dev/null; then - # Process each CSV file in the aggregation directory - for file in ${files}; do - # Extract the metric name (e.g., AHF from AHF.90th_percentile.csv) - metric=$(basename "${file}" | cut -d '.' -f 1) - - # Extract values from the CSV file - value=$(<"${file}") - - # Check which aggregation type this file corresponds to and store it accordingly - if [[ "${file}" =~ \.90th_percentile\.csv$ ]]; then - percentile="${value}" - mean="" - median="" - elif [[ "${file}" =~ \.mean\.csv$ ]]; then - mean="${value}" - elif [[ "${file}" =~ \.median\.csv$ ]]; then - median="${value}" - fi - - # Sanitize the values before inserting into the LaTeX table - percentile=$(latex_escape "${percentile}") - mean=$(latex_escape "${mean}") - median=$(latex_escape "${median}") - - # Write the row for this metric to the LaTeX table - if [[ -n "${percentile}" && -n "${mean}" && -n "${median}" ]]; then - printf "%s & %s & %s & %s \\\\\\\\\\\\\ \n" "${metric}" "${percentile}" "${mean}" "${median}" >> "${aggregation_table}" - fi - done +shopt -s nullglob +files=("${TARGET}/data/aggregation/"*.csv) +shopt -u nullglob + +if [ "${#files[@]}" -gt 0 ]; then + for file in "${files[@]}"; do + metric=$(basename "${file}" | cut -d '.' -f 1) + value=$(<"${file}") + if [[ "${file}" =~ \.90th_percentile\.csv$ ]]; then + percentile="${value}" + mean="" + median="" + elif [[ "${file}" =~ \.mean\.csv$ ]]; then + mean="${value}" + elif [[ "${file}" =~ \.median\.csv$ ]]; then + median="${value}" + fi + percentile=$(latex_escape "${percentile}") + mean=$(latex_escape "${mean}") + median=$(latex_escape "${median}") + if [[ -n "${percentile}" && -n "${mean}" && -n "${median}" ]]; then + printf "%s & %s & %s & %s \\\\\\\\\\\\\ \n" "${metric}" "${percentile}" "${mean}" "${median}" >> "${aggregation_table}" + fi + done fi # Close the LaTeX table