Reputation: 3318
I have many files inside 1 folder. This is a description of names:
AWA_s1_Fp1_features.mat
AWA_s1_C3_features.mat
AWA_s1_C4_features.mat
AWA_s1_Fp2_features.mat
Rem_s1_Fp1_features.mat
Rem_s1_C3_features.mat
Rem_s1_C4_features.mat
Rem_s1_Fp2_features.mat
SWS_s1_Fp1_features.mat
SWS_s1_C3_features.mat
SWS_s1_C4_features.mat
SWS_s1_Fp2_features.mat
s1 goes from 1 to 38.
So, how can I call them? For example I only want to call the AWA_sx_C3 ones: AWA_s1_C3_features.mat, AWA_s2_C3_features.mat ...AWA_s38_C3_features.mat
How can I do it? With this code I call all the AWA files (C3, C4, Fp1 and Fp2). But I only want the C3 ones.
read_files = glob.glob('/media/FeaturesX/AWA_s*.mat')
Upvotes: 0
Views: 19
Reputation: 36608
Try this:
read_files = glob.glob('/media/FeaturesX/AWA_s*_C3_features.mat')
The pattern matching in glob
is fairly literal. By putting _C3_features.mat
after the *
, we require that part of the string to exist for the match to be valid.
Upvotes: 1