python - remove first line of tsv using sniffer -


i have code this. trying remove first line of tsv file have field names, field1, field2,.., fieldn.

  1. is wrong piece of code. dont dialect part right. @ present gives attributeerror: 'function' object has no attribute 'readline.

  2. also there way can give field names header read. tried doing csv.sniffer().has_header method no luck.

please

with open('outfile.txt','rb') tsvin:   dialect=csv.sniffer().sniff.readline(1024)   tsvin.seek(0)   reader=csv.reader(tsvin,dialect,delimiter='\t')   #has_header=csv.sniffer().has_header(inf.read(1024))  row in tsvin:   tsid= row[0]   full_list.append(tsid)   print [(g[0],len(list(g[1]))) g in itertools.groupby(full_list)] 

i got right:

data= csv.reader(open('outfile.tsv','rb'), delimiter = "\t") fields=data.next() row in data:          tsid=row[0]          full_list.append(tsid) print [(g[0],len(list(g[1]))) g in itertools.groupby(full_list)] 

Comments