#!/bin/csh -f

# Merge on deployment number rather than year
set n_deployment = (1 2)

# 21/4/2016 - at change of year in 2015 there was an additional Nnitrate column added.  
# This causes problems which haven't been thoroughly ironed out.
set n_deployment = 2

foreach deployment($n_deployment)
   set files = `ls ????/E1_buoy_????_AWS_deployment${deployment}_merged.csv`
   echo $files
   foreach file($files)
      set header = `cat $file | awk '/YYMMDD/{print $0}'`
   end
   set nfile = `echo ../level3/E1_buoy_AWS_deployment${deployment}_merged.csv`
   echo $header > $nfile
   
   foreach file($files)
      cat $file | tail -n +2 >> $nfile
   end

end



exit(0)

