I have a string which is basically the header of a CSV file from which i have to extract the month and then convert it to a string by appending a single '0' in front of it to compare with other value.
header --
HGLOABCD8PSGL_ZXFH J20190603NXT_APAC
from this i need to to extract the month from the 20190603 which is 06 and then create a list like ['006', '005'] second element of the list will be previous month of the given month in the header
also the header could also be like where month is different
HGLOABCD8PSGL_ZXFH J20191003NXT_APAC
i have written something like this for first element but not sure how can i substract one month then append '0' to it.
acc_period = []
acc_period.append('0'+str(header)[26:28])
acc_period.append(int('0') + int(str(header)[26:28])-1)
print (acc_period)