def test_read_csv_lines_one_column(infile): # Just a basic test, next one with unicode eq_( list(read_csv_lines(infile)), [ {u'h1': u'v1'}, {u'h1': u'v2'}, ] )
def test_read_csv_lines_tsv_unicode(infile): # Just a basic test, next one with unicode gen = read_csv_lines(infile) ok_generator(gen) eq_(list(gen), [ { u'h1': u'v1', u'h2': u'дата' }, ])
def test_read_csv_lines_tsv_unicode(infile): # Just a basic test, next one with unicode gen = read_csv_lines(infile) ok_generator(gen) eq_( list(gen), [ {u'h1': u'v1', u'h2': u'дата'}, ] )
def test_read_csv_lines_basic(infile=None): # Just a basic test, next one with unicode gen = read_csv_lines(infile) ok_generator(gen) eq_(list(gen), [ { u'h1': u'v1', u'h2': u'2' }, { u'h1': u'v2', u'h2': u'3' }, ])
def yield_participant_info(fname): for row in read_csv_lines(fname): if 'participant_id' not in row: # not sure what this is, but we cannot use it break # strip a potential 'sub-' prefix if row['participant_id'].startswith('sub-'): row['participant_id'] = row['participant_id'][4:] props = {} for k in row: # take away some ambiguity normk = k.lower() hk = content_metakey_map.get(normk, normk) val = row[k] if hk in ('sex', 'gender'): val = sex_label_map.get(row[k].lower(), row[k].lower()) if val: props[hk] = val if props: yield re.compile(r'^sub-{}/.*'.format( row['participant_id'])), props