Guest User

Untitled

a guest
Feb 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. d_csv2 = {}
  2.  
  3. with open('subscriber_info 02212018.csv', 'r') as f_csv2:
  4. csv_2 = csv.reader(f_csv2)
  5. for cols in csv_2:
  6. d_csv2[cols[1]] = cols[0], cols[2]
  7.  
  8.  
  9. with open('subscribersWithMultipleDevices.csv', 'r') as f_csv1, open('output.csv', 'w', newline='') as f_output:
  10. csv_1 = csv.reader(f_csv1)
  11. csv_output = csv.writer(f_output)
  12. csv_output.writerow(['Customer', 'Email', 'First Name', 'Last Name', 'Serial Number', 'WAN MAC', 'IP ADD', 'Model',
  13. 'Last Contact', 'Circuit ID', 'n'])
  14.  
  15. for cols in csv_1:
  16. try:
  17. if cols[6] in d_csv2:
  18. csv_output.writerow(cols + [d_csv2[cols[6]]])
  19. except KeyError:
  20. print('key error')
Add Comment
Please, Sign In to add comment