I have a directory(data
) that contain thousand of files.Each time I want to select three
files that are just differ by only one characterAB[C,D,E]
and want to perform some computation on the selected three files later.
My files are present inside the directory as follows
DT.ABC.2007.182.144018.txt
DT.ABD.2007.182.144018.txt
DT.ABE.2007.182.144018.txtDT.ABC.2001.005.1444.txt
DT.ABD.2001.005.1444.txt
DT.ABE.2001.005.1444.txtDT.ABC.2003.005.1244.txt
DT.ABD.2003.005.1244.txt
DT.ABE.2003.005.1244.txt
and at first i want to print
DT.ABC.2007.182.144018.txtDT.ABD.2007.182.144018.txtDT.ABE.2007.182.144018.txt
then
DT.ABC.2001.005.1444.txt
DT.ABD.2001.005.1444.txt
DT.ABE.2001.005.1444.txt
and same process would goes on until finishing reading all the files in the directory.
I tried the code below:
import glob
for file in glob.glob('/data/*.txt'):print(st)
But it print all the files randomly instead of printing the same three(differ only by [C,D,E]
character.I hope experts may help me.Thanks in advance.