我正在尝试编写一个函数,用于查找特定目录并查找特定文件格式的匹配项
函数格式如下:
def file_pattern_match(self, fundCodes, startDate, endDate):
# set a file pattern
file_pattern = 'unmapped_{fund}_{start}_{end}.csv'.format(fund=somethinghere, 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
这就是我有点困惑的地方fundCodes
将是一个基金代码数组。因此,此函数必须搜索目录中的文件,并查看是否存在匹配项
称之为:
file_pattern_match(['FUND1', 'FUND2', 'FUND3'], '20180203', '20180204')
应该找到如下文件:
unmapped_FUND1_20180203_20180204.csv
我曾考虑过使用正则表达式,但我不确定如何使用字符串数组
假设您的函数需要返回一个数据帧,并且只有一个代码与您的函数看起来像的文件相匹配
相关问题 更多 >
编程相关推荐