added a bunch of helper scripts
This commit is contained in:
parent
f72408cd88
commit
a24aeeffe7
6 changed files with 347 additions and 0 deletions
30
add_csv_header.sh
Executable file
30
add_csv_header.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Usage: ./add_csv_header.sh /path/to/trace_root
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 /path/to/trace_root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TRACE_ROOT="$1"
|
||||
HEADER="experiment_name,chain,mean,std,min,max,count"
|
||||
|
||||
if [[ ! -d "$TRACE_ROOT" ]]; then
|
||||
echo "Error: '$TRACE_ROOT' is not a directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find all results.csv files one level below the trace root
|
||||
find "$TRACE_ROOT" -mindepth 2 -maxdepth 2 -type f -name results.csv | while IFS= read -r csvfile; do
|
||||
# Insert header only if not already present
|
||||
first_line=$(head -n 1 "$csvfile")
|
||||
if [[ "$first_line" != "$HEADER" ]]; then
|
||||
echo "Adding header to $csvfile"
|
||||
sed -i "1i$HEADER" "$csvfile"
|
||||
else
|
||||
echo "Header already present in $csvfile, skipping."
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue