Skip to content

Commit

Permalink
Added create_csv.py to ease the creation of the CSV file for new users.
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Wagner committed Jun 25, 2012
1 parent c6e3c11 commit e4a2e86
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions doc/source/src/create_csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import sys
import os.path

# This is a tiny script to help you creating a CSV file from a face
# database with a similar hierarchie:
#
# philipp@mango:~/facerec/data/at$ tree
# .
# |-- README
# |-- s1
# | |-- 1.pgm
# | |-- ...
# | |-- 10.pgm
# |-- s2
# | |-- 1.pgm
# | |-- ...
# | |-- 10.pgm
# ...
# |-- s40
# | |-- 1.pgm
# | |-- ...
# | |-- 10.pgm
#

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

0 comments on commit e4a2e86

Please sign in to comment.