So I have a script where I loops through a set of files in a folder. After retrieving the list of files in that particular directory, how do I specify which files I want to use in the script?
target = './directory/'
for file in listdir(target):
Now I have several different files in the same folder.
- kplr006933899-2009131105131_llc.fits
- kplr006933899-2009131105131_lpd-targ.fits
- kplr006933899-2012151031540_slc.fits
- kplr006933899-2012151031540_spd-targ.fits
They all are part of the same group, which is denoted by "kplr006933899". How can I specify parts of the strings as different variable in order to specify which files I want to loop through?
Like for example:
def function(name,types)
where you could write when called:
function(kplr006933899,[slc,llc])
kplr+ some number and that contain specific other substrings or you simply want to filter the names that start withkplrand contain some substring?