-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseProjectData.py
More file actions
27 lines (22 loc) · 808 Bytes
/
parseProjectData.py
File metadata and controls
27 lines (22 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from os import walk, path
def parseProjectData(pathname):
def list_files(dirpath, files=[]):
for (curdir, dirs, filenames) in walk(dirpath):
for file in filenames:
files.append((file, curdir))
if(len(dirs) > 0):
for dir in dirs:
list_files(dir, files)
return files
def parse_data(files, keyword):
data = {}
for filename, dirpath in files:
if filename == keyword:
subject_id = path.basename(dirpath)
if subject_id in data:
data[subject_id].append(dirpath)
else:
data[subject_id] = [dirpath]
return data
files = list_files(pathname)
return parse_data(files, 'summary.csv')