One of my folders has mostly json files, and I'm reading the data they contain to do some classification for an SVM. A question I had was based on this code:
for filename in os.listdir(os.getcwd()):
if re.search('.json$',filename):
try:
with open(filename) as json_data:
print filename
Each time I pipe the output, I find that the filenames always get printed in the same order, like so:
95231464576.json
131777220274261.json
17151210249.json
122624927762214.json
159287900855286.json
155273941171682.json
5265971983.json
169635939813776.json
159429967503904.json
169114363192327.json
170797436313930.json
155963124522916.json
There are a few text files, and some python files in this directory.
My question here is: what determines the order in which these files are printed? Does the for loop have a way of looking for files?
I tried examining whether this order is based on size (max to min or min to max) or last modified(I had no reason for these tests,I just tried them since I can't think of any other insight).
I tried this snippet 4 times, and the order is the same each time.
I have a labelled classes in different folders, so if I can be assured of the order it would be helpful in the labeling for my training set(I don't know how good an idea this is).