Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1.  
  2. class Course:#course object
  3. def __init__(self,name,idnum,confl):#course name
  4. self.name=name
  5. self.idnum=idnum
  6. self.confl=list(confl)
  7. def __str__(self):
  8. return(self.name + self.idnum + str(self.confl) + '\n')
  9. __repr__=__str__
  10.  
  11.  
  12. def main():
  13. #global t
  14. #t = [1,2,3]
  15. CourseList=[]
  16. cc(CourseList)
  17.  
  18. def cc(CL):
  19. f = open(' FILE PATH TO courses.csv')
  20. for line in f:
  21. cn = 0
  22. a = None
  23. b = None
  24. c = []
  25. line = line.strip()
  26. for word in line.split(','):
  27. if cn==0:
  28. a = word
  29. cn = 1
  30. elif cn==1:
  31. b = word
  32. cn = 2
  33. elif cn>1 and word!='':
  34. for small in word.split(' '):
  35. if small!='':
  36. c.append(small)
  37. cn = 0
  38. # CL.append([a,b,c])
  39. newCourse = Course(a,b,c)
  40. check(CL, newCourse)
  41. CL.append(newCourse)
  42. f.close()
  43. print(CL)
  44.  
  45. def check(CL, nc):
  46. for course in CL:
  47. for cfl in nc.confl:
  48. print(cfl+" "+course.idnum)
  49. print(cfl==course.idnum)
  50. if cfl==course.idnum:
  51. print("I got here")
  52. course.confl.append(nc.idnum)
  53.  
  54. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement