Created
June 26, 2014 05:57
-
-
Save AbhiAgarwal/ec3ae671921e31978a34 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
#!/usr/bin/env python | |
import sys | |
import os.path | |
if __name__ == "__main__": | |
if len(sys.argv) != 2: | |
print "usage: create_csv <base_path>" | |
sys.exit(1) | |
BASE_PATH = sys.argv[1] | |
SEPARATOR = ";" | |
label = 0 | |
for dirname, dirnames, filenames in os.walk(BASE_PATH): | |
for subdirname in dirnames: | |
subject_path = os.path.join(dirname, subdirname) | |
for filename in os.listdir(subject_path): | |
abs_path = "%s/%s" % (subject_path, filename) | |
print "%s%s%d" % (abs_path, SEPARATOR, label) | |
label = label + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to use this