Skip to content

Commit

Permalink
bids-combine.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Jun 2, 2024
1 parent 3a3dcb2 commit 9553efc
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions scripts/bids-combine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
#
# Combine bid CSVs (from bidcollect) into a single CSV
#
set -e

# require directory as first argument
if [ -z "$1" ]; then
echo "Usage: $0 <directory>"
exit 1
fi

cd $1
date=$(basename $1)
echo $date

# ALL BIDS
fn_out="all_${date}.csv"
rm -f $fn_out
echo "Writing to ${fn_out}"

first="1"
for fn in $(\ls all*); do
echo "- ${fn}"
if [ $first == "1" ]; then
head -n 1 $fn > $fn_out
first="0"
fi
tail -n +2 $fn >> $fn_out
done
zip "${fn_out}.zip" $fn_out
rm -f $fn_out
echo "Wrote ${fn_out}.zip"

# TOP BIDS
fn_out="top_${date}.csv"
rm -f $fn_out
echo "Writing to ${fn_out}"

first="1"
for fn in $(\ls top*); do
echo "- ${fn}"
if [ $first == "1" ]; then
head -n 1 $fn > $fn_out
first="0"
fi
tail -n +2 $fn >> $fn_out
done
zip "${fn_out}.zip" $fn_out
rm -f $fn_out
echo "Wrote ${fn_out}.zip"

0 comments on commit 9553efc

Please sign in to comment.