Feed on

Use CSV module and DictReader:

taxa_fn = img_dn + “/00.taxon.tab.txt”
taxa_d = {}
with open(taxa_fn, ‘rb’) as taxa_f:
csv_o = csv.DictReader(taxa_f, delimiter=’\t’)
for line_d in csv_o:
oid_n = line_d['taxon_oid']
name_s = line_d['taxon_display_name']
domain_s = line_d['domain']
status_s = line_d['seq_status']
taxa_d[oid_n] = {‘name’:name_s,’domain’:domain_s,’status’:status_s}

Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

Did I get this wrong? Let me know!

Trackback URI | Comments RSS