Guest User

Untitled

a guest
May 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import csv
  2.  
  3. from dumbo import main
  4.  
  5.  
  6. def load_contratos_mapper(contratos_files):
  7. contratos = {}
  8. try:
  9. # Read table - medal|prize|country|year
  10. with open(contratos_files) as f:
  11. reader = csv.reader(f, delimiter=';', quotechar='"', doublequote=False)
  12. reader.next()
  13. for line in reader:
  14. contratos[(line[0], line[1], line[2], lin[3], line[4])] = line[5]
  15.  
  16. except:
  17. pass
  18.  
  19. return contratos
  20.  
  21.  
  22. class Join_contratos_reduce:
  23. def __init__(self):
  24. self.contratos = load_contratos('./Contratos_por_municipio.csv')
  25.  
  26. def __call__(self, key, values):
  27. try:
  28. values.groupby([1])[5].sum()
  29. yield values
  30.  
  31. except:
  32. pass
  33.  
  34. def runner(job):
  35. inout_opts = [("inputformat", "text"), ("outputformat", "text")]
  36. o1 = job.additer(load_contratos_mapper, Join_contratos_reduce, opts=inout_opts)
  37.  
  38.  
  39. if __name__ == "__main__":
  40. main(runner)
Add Comment
Please, Sign In to add comment