Skip to content

Instantly share code, notes, and snippets.

@Rafhack
Last active January 22, 2019 18:24
Show Gist options
  • Save Rafhack/109330b794931c705bc9b84e309090c0 to your computer and use it in GitHub Desktop.
Save Rafhack/109330b794931c705bc9b84e309090c0 to your computer and use it in GitHub Desktop.
#!/bin/bash
order=("screenName" "eventCategory" "eventAction" "eventLabel")
printf '%s;' ${order[@]} > $1.csv
echo >> $1.csv
while IFS='' read -r line || [[ -n "$line" ]]; do
if ! [[ "$line" == *"Passing"* ]]; then continue; fi
IFS=',' read -r -a split <<< "$line"
csvline=""
for key in ${order[@]}; do
for i in `seq 0 ${#split[@]}`; do
IFS='=' read -r -a sub_split <<< "${split[$i]}"
if [[ ${sub_split[0]#*Bundle\[\{} == "$key" || ${sub_split[0]## } == "$key" ]]; then
csvline+="${sub_split[1]%\}]*};"
fi
done
done
if ! [[ ${events[*]} =~ "$csvline" ]]; then
events+=("$csvline")
echo "$csvline" | tee -a $1.csv
fi
done < "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment