Advertisement
Haunt

Untitled

Aug 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. due_dict = {}
  2. missing_ids = []
  3.  
  4. with open('CLIO_TASKS.csv', mode='r', newline='', encoding='utf-8') as CLIO_TASKS:
  5.     for clio_line in CLIO_TASKS:
  6.         clio_line = clio_line.split(",")
  7.         task_id = clio_line[0][1:-1]
  8.         due_date = clio_line[3]
  9.         due_dict[task_id] = due_date
  10.     CLIO_TASKS.close()
  11.     print("dictionary created!\n")
  12.  
  13. dict_keys = due_dict.keys()
  14.  
  15.  
  16. def find_due_date(orig_id):
  17.     if orig_id in dict_keys:
  18.         return due_dict[orig_id]
  19.     else:
  20.         missing_ids.append(orig_id)
  21.         return "0"
  22.  
  23.  
  24. out_date = ""
  25.  
  26. with open('MVS_TASKS.csv', mode='r', newline='',encoding='utf-8') as MVS_TASKS,\
  27.      open('MVS_TASKS_JOINED.csv', mode='a', newline='', encoding='utf-8') as MVS_TASKS_JOINED:
  28.     MVS_TASKS.readline()
  29.     for line in MVS_TASKS:
  30.         line_holder = line
  31.         line = line.split(", ")
  32.         engagement_id = line[0]
  33.         out_date = find_due_date(engagement_id)
  34.         print(out_date)
  35.         MVS_TASKS_JOINED.write(line_holder.strip() + out_date.strip() + "\n")
  36. MVS_TASKS_JOINED.close()
  37. MVS_TASKS.close()
  38.  
  39. with open('MISSING.txt', mode='a') as MISSING:
  40.     MISSING.write(''.join(missing_ids))
  41. MISSING.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement