I'm having a lot of trouble figuring out how to figure out this file pattern. I have the following code:
def file_pattern_match(self, fundCode, startDate, endDate):
# check if the fundcode is in the array or if the fundcode matches one in the array
fundCode = fundCode if fundCode in self.fundCodes else 'Invalid_Fund_Code'
# set a file pattern
file_pattern = 'unmapped_{fund}_{start}_{end}.csv'.format(fund=fundCode, start=startDate, end=endDate)
# look in the unmappedDir and see if there's a file with that name
# if the there is load the positions
pass
This is a funciton that's part of a class. There's one issue. I just realized that the parameter fundCode will actually be an array of values, so I need to use some sort of delimiter. In the end, I want to look for files matching this kind of pattern:
unmapped_FUND1_FUND2_FUNDETC_20180203_20180204.CSV or
unmapped_FUND1_20180203_20180204.CSV
I'm guessing regex would be a good use for this?