modified script to throw error on empty values and to set non-values to 'NA'