Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jovi1994 committed Dec 12, 2024
1 parent ae8c473 commit 2a0ac12
Showing 1 changed file with 24 additions and 34 deletions.
58 changes: 24 additions & 34 deletions steps/report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2a0ac12

Please sign in to comment.