SHARE
TWEET

Untitled

a guest Oct 13th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import csv
  2.  
  3. names = []
  4. emails = []
  5. phoneNumbers = []
  6. year = []
  7. department = []
  8. teamInterested = []
  9. with open("data.csv", "r") as file:
  10.     row = csv.DictReader(file)
  11.     for line in row:
  12.         names.append(line["name"])
  13.         emails.append(line["email"])
  14.         phoneNumbers.append(line["phoneNumber"])
  15.         year.append(line["year"])
  16.         department.append(line["department"])
  17.         teamInterested.append(line["teamInterested"])
  18. roles = ["technical", "designing", "media", "management"]
  19.  
  20. technical = []
  21. designing = []
  22. media = []
  23. management = []
  24. for i in range(len(names)):
  25.     if "Technical" in teamInterested[i]:
  26.         technical.append(i)
  27.     if "Designing" in teamInterested[i]:
  28.         designing.append(i)
  29.     if "Media" in teamInterested[i]:
  30.         media.append(i)
  31.     if "Management" in teamInterested[i]:
  32.         management.append(i)
  33.  
  34. for i in technical:
  35.     row = []
  36.     row.append(names[i])
  37.     row.append(emails[i])
  38.     row.append(phoneNumbers[i])
  39.     row.append(year[i])
  40.     row.append(department[i])
  41.     with open("technical.csv", "a") as data:
  42.         writer = csv.writer(data)
  43.         writer.writerow(row)
  44.  
  45. for i in designing:
  46.     row = []
  47.     row.append(names[i])
  48.     row.append(emails[i])
  49.     row.append(phoneNumbers[i])
  50.     row.append(year[i])
  51.     row.append(department[i])
  52.     with open("designing.csv", "a") as data:
  53.         writer = csv.writer(data)
  54.         writer.writerow(row)
  55.  
  56. for i in media:
  57.     row = []
  58.     row.append(names[i])
  59.     row.append(emails[i])
  60.     row.append(phoneNumbers[i])
  61.     row.append(year[i])
  62.     row.append(department[i])
  63.     with open("media.csv", "a") as data:
  64.         writer = csv.writer(data)
  65.         writer.writerow(row)
  66.  
  67. for i in management:
  68.     row = []
  69.     row.append(names[i])
  70.     row.append(emails[i])
  71.     row.append(phoneNumbers[i])
  72.     row.append(year[i])
  73.     row.append(department[i])
  74.     with open("management.csv", "a") as data:
  75.         writer = csv.writer(data)
  76.         writer.writerow(row)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top