Created
June 10, 2015 20:45
-
-
Save bliz937/1005f091c7f7026ee363 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
imgDIR = "D:\\!current\\nathan\\cohn-kanade\\" | |
outDIR = "D:\\!current\\nathan\\output\\" | |
CSV = "D:\\!current\\nathan\\CK.database.FACS.csv" | |
fileSlash = "\\" | |
import csv | |
import os | |
import shutil | |
def subjectFix(subject): | |
while(len(subject) != 3): | |
subject = "0" + subject | |
return "S" + subject | |
def copyImage(subject, session, imageNo): | |
copyDIR = outDIR + imageNo | |
if(not os.path.exists(copyDIR)): | |
os.makedirs(copyDIR) | |
src = imgDIR + subjectFix(subject) + fileSlash + session | |
dst = copyDIR + fileSlash + subject + "." + session | |
print("subject: %s\tsession: %s\tImageNo: %s" % (subject,session,imageNo)) | |
shutil.copytree(src, dst) | |
def readCSV(): | |
with open(CSV, 'rb') as csvfile: | |
csvData = csv.reader(csvfile, delimiter=',', quotechar='"') | |
for row in csvData: | |
subject = row[0] | |
session = row[1] | |
for i in xrange(3,20): | |
ac = row[i] | |
if(ac != "" and ac != "F"): | |
copyImage(subject, session, ac) | |
if(__name__ == "__main__"): | |
readCSV() | |
print("Done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment