Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. '''
  2. def(pseudocode)
  3.  
  4. iterate through rows # this instructs it to run through the document
  5. create dictionary
  6. call install date to a date
  7. call replacement date to a date
  8. if sheeting is blank and replacement date == None
  9. use install date sheeting #while doing this I need it to follow the primary parameters and special parameters
  10. if sheeting is blank and replacement date > install date
  11. use replacement date sheeting
  12. if sheeting != None and replacement date > install date
  13. use replacement date sheeting
  14. if sheeting != None and replacement date == None
  15. use install date sheeting
  16.  
  17. primary parameters #parameters for the "normal" signs
  18. if install date is 1960-1988
  19. sheeting type 3
  20. if install date is 1989-1998
  21. sheeting type 8
  22. if install date is 1999-2006
  23. sheeting type 9
  24. if install date is 2007-2013
  25. sheeting type 11
  26. if install date is > 2014 and is not in special parameters
  27. sheeting type 4
  28.  
  29. special parameters #parameters for the "special" signs
  30. if code starts with D and has certain support type
  31. use type 11
  32. if code starts with OH
  33. use type 11
  34. if code starts with MA
  35. If code starts with R
  36. use type 11
  37. if code starts with W
  38. use type 11
  39. if code contains 'x4-13w'
  40. if installdate >= 2014
  41. use type 4
  42. else
  43. use type 9
  44. if code contains 'x4-13w'
  45. if installdate >= 2014
  46. use type 4
  47. else
  48. use type 3
  49. '''
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. '''
  61. import openpyxl
  62. from datetime import datetime
  63.  
  64. wb = openpyxl.load_workbook('Export3test.xlsm', keep_vba = True)
  65. ws = wb.active
  66.  
  67. conDate = input('Enter the construction date in YYYY-MM-DD format: ')
  68. cDate = datetime.strptime(conDate,'%Y-%m-%d')
  69.  
  70. for row in ws.iter_rows(min_row=4, max_col=52, max_row=ws.max_row):
  71. columns = {cell.column:cell for cell in row}
  72. installDate = datetime.strptime(columns['AI'].value, '%Y-%m-%d') if columns['AI'].value is not None else None
  73. replacementDate = datetime.strptime(columns['AJ'].value, '%Y-%m-%d') if columns['AJ'].value is not None else None
  74. if all([installDate, replacementDate]): # both dates must be dates and thus NOT None
  75. if installDate <= cDate and replacementDate >= cDate:
  76. columns['AI'].value = cDate
  77. elif installDate <= cDate and replacementDate <= cDate:
  78. columns['AI'].value = '1959-01-01'
  79. elif any([installDate, replacementDate]): # at least one of those dates are NOT None
  80. if installDate is None:
  81. if replacementDate >= cDate:
  82. columns['AI'].value = cDate
  83. elif replacementDate <= cDate:
  84. columns['AI'].value = '1959-01-01'
  85. elif installDate < cDate and [installDate.day, installDate.month] == [1, 1]: # Can you do this list comparison anytime?
  86. columns['AI'].value = cDate
  87. else:
  88. columns['AI'].value = cDate
  89.  
  90.  
  91. wb.save('Export3final.xlsm')
  92.  
  93. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement