I have some files in this format that I need to return the oldest and newest files to pass to a function for parsing
Nv_NODE_DATE_TIME
I would like the output to be
Nv_stats_172550_160211_230030
Nv_stats_172550_160212_142624
Nv_stats_75AKPD0_160211_230030
Nv_stats_75AKPD0_160212_142624
but I am getting the absolute first item and absolute last item
Nv_stats_172550_160211_230030
Nv_stats_75AKPD0_160212_142624
Nv_stats_172550_160211_230030
Nv_stats_75AKPD0_160212_142624
Here is the current code
import os
iostatslocalpath="/root/svc/testing/"
svchost='SVC_Cluster01'
nodenames=['75AKMX0', '75AKPD0', '172550', '172561']
filelist=sorted(os.listdir(iostatslocalpath+svchost+'/.'))
totalfilenumber=len(filelist)
def parse(filename, length):
print filename[0]
print test[length-1]
for nodename in nodenames:
test=[]
test[:]=[]
for file in filelist:
if nodename and "Nv" in file:
test.append(file)
parse(test, len(test))
There is probably something small I am overlooking, any help would be appreciated