# /bin/bash

# Before executing this script, the delta between the qualifiers must have been calculated
# This script adds a column to all the files with the filtered qualifiers. The assumption is that they are named:
# delta20191202_20191209_P580_P582_P585_filtered.tsv. The date in the column will be the second one to appear
# After this script is run, the generated files should be aggregated in a big cat command.

folder=deltas_qual_temporal
output=out_with_date
mkdir "$folder"/"$output"
for entry in "$folder"/*
do
	echo "Dealing with entry: " $entry
	f=$(basename "$entry") 
	date=${f:14:8}
	kgtk calc -i $entry --value $date --into 'node2;date' --do set -o "$folder"/"$output"/date_"$f"
done
