rename from CSV
path = 'Malware500'
tmp_path = 'data'
with open('Malware500.csv','rb') as csvfile:
reader = csv.reader(csvfile, delimiter = ',')
for row in reader:
oldname = os.path.join(path, row[0])
if os.path.exists(oldname):
newname = os.path.join(tmp_path, row[1])
os.rename(oldname, newname)
print >> sys.stderr, "renamed '%s' to '%s'" % (oldname, newname)
else:
print >> sys.stderr, "file '%s' not found" % oldname
tmp_path = 'data'
with open('Malware500.csv','rb') as csvfile:
reader = csv.reader(csvfile, delimiter = ',')
for row in reader:
oldname = os.path.join(path, row[0])
if os.path.exists(oldname):
newname = os.path.join(tmp_path, row[1])
os.rename(oldname, newname)
print >> sys.stderr, "renamed '%s' to '%s'" % (oldname, newname)
else:
print >> sys.stderr, "file '%s' not found" % oldname
댓글
댓글 쓰기