dirList=os.listdir(data_path) for fname in dirList: file = data_path+fname f = h5py.File(file) group_name = f.attrs['group_name'] number_in_group = f.attrs['number_in_group'] species = f.attrs['species'] location = f.attrs['location'] subject = session.query(db.Subject).\ filter_by(species=species, group_name=group_name, number_in_group=number_in_group).first() if not subject: subject = db.Subject(species=species, group_name=group_name, number_in_group=number_in_group) session.add(subject) session.commit() print file conditions = [(v,t,e,s,rem) for v in visits for t in tasks for e in eyes for s in sensors for rem in remicas] for visit, task_type, eye, sensor_type, rem in conditions: base = str(visit)+'/'+task_type+'/'+eye+'/'+sensor_type+'/'+rem base_filtered = base+'/filter_'+filter_type+'_'+str(taps)+'_'+window #If this particular set of conditions doesn't exist for this subject, just continue to the next set of conditions try: f[base_filtered] except KeyError: continue print base if group_name=='GSK1':