Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- def(pseudocode)
- iterate through rows # this instructs it to run through the document
- create dictionary
- call install date to a date
- call replacement date to a date
- if sheeting is blank and replacement date == None
- use install date sheeting #while doing this I need it to follow the primary parameters and special parameters
- if sheeting is blank and replacement date > install date
- use replacement date sheeting
- if sheeting != None and replacement date > install date
- use replacement date sheeting
- if sheeting != None and replacement date == None
- use install date sheeting
- primary parameters #parameters for the "normal" signs
- if install date is 1960-1988
- sheeting type 3
- if install date is 1989-1998
- sheeting type 8
- if install date is 1999-2006
- sheeting type 9
- if install date is 2007-2013
- sheeting type 11
- if install date is > 2014 and is not in special parameters
- sheeting type 4
- special parameters #parameters for the "special" signs
- if code starts with D and has certain support type
- use type 11
- if code starts with OH
- use type 11
- if code starts with MA
- If code starts with R
- use type 11
- if code starts with W
- use type 11
- if code contains 'x4-13w'
- if installdate >= 2014
- use type 4
- else
- use type 9
- if code contains 'x4-13w'
- if installdate >= 2014
- use type 4
- else
- use type 3
- '''
- '''
- import openpyxl
- from datetime import datetime
- wb = openpyxl.load_workbook('Export3test.xlsm', keep_vba = True)
- ws = wb.active
- conDate = input('Enter the construction date in YYYY-MM-DD format: ')
- cDate = datetime.strptime(conDate,'%Y-%m-%d')
- for row in ws.iter_rows(min_row=4, max_col=52, max_row=ws.max_row):
- columns = {cell.column:cell for cell in row}
- installDate = datetime.strptime(columns['AI'].value, '%Y-%m-%d') if columns['AI'].value is not None else None
- replacementDate = datetime.strptime(columns['AJ'].value, '%Y-%m-%d') if columns['AJ'].value is not None else None
- if all([installDate, replacementDate]): # both dates must be dates and thus NOT None
- if installDate <= cDate and replacementDate >= cDate:
- columns['AI'].value = cDate
- elif installDate <= cDate and replacementDate <= cDate:
- columns['AI'].value = '1959-01-01'
- elif any([installDate, replacementDate]): # at least one of those dates are NOT None
- if installDate is None:
- if replacementDate >= cDate:
- columns['AI'].value = cDate
- elif replacementDate <= cDate:
- columns['AI'].value = '1959-01-01'
- elif installDate < cDate and [installDate.day, installDate.month] == [1, 1]: # Can you do this list comparison anytime?
- columns['AI'].value = cDate
- else:
- columns['AI'].value = cDate
- wb.save('Export3final.xlsm')
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement