     nopunct = (s) -> s.replace(/[\s'\.,-:;]/g, "")
     unique = {}
     for r in purposes
+      if not r.code? then r.code = "00000"
+      if not r.name? then r.name = "Unknown"
+
       r.name = r.name.trim()
       uname = r.name.toUpperCase()
       




  @get '/aiddata-purposes-with-totals.csv': ->
    pg.sql "select
              purpose_code as code,

    _.values(unique)


  # Returns a list of the known purposes
  @get '/aiddata-purposes.csv': ->
    pg.sql "select distinct(purpose_code) as code,purpose_name as name
              from donor_recipient_year_purpose_ma 
