i have code this. trying remove first line of tsv file have field names, field1, field2,.., fieldn.
is wrong piece of code. dont dialect part right. @ present gives attributeerror: 'function' object has no attribute 'readline.
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
Post a Comment