I am using Python 2.7.3 btw
Hi all,
I have a little problem. The problem is that I keep running into trouble with the starred line below. (Sorry, kinda new to Python)
So here is my code so far:
with open('parsedChr','w') as fout, open('heartLungClassU.gtf','r') as filein:
average = 0
difference = 0
position = ''
bp = 0
for line in filein:
**chrom,cuff,exon,start,end,dot,sign,dots,gene,tranid,exonid,rest = line.split('\t',11)**
## notice 12 variables here so I tried to unpack with value 11
##more code after
I keep getting this error:
Traceback (most recent call last):
File "parse.py", line 11, in <module>
chrom,cuff,exon,start,end,dot,sign,dots,gene,tranid,exonid,rest = line.split('\t',11)
ValueError: need more than 9 values to unpack
I don't understand why though -- note that there are 12 variables I am splitting the line into. Why would python complain about needing more than 9 values to unpack? I've had code before where I had to split into 6 variables and so used 5 in line.split (5 cuts into 6 pieces, as I understood it), but I don't understand why similar logic doesn't work here.
EDIT: here is a portion of the file:
chr1 Cufflinks exon 14765607 14765689 . + . gene_id "XLOC_000018"; transcript_id "TCONS_00001260"; exon_number "1"; oId "CUFF.68.1"; class_code "u"; tss_id "TSS40";
chr1 Cufflinks exon 14766604 14767199 . + . gene_id "XLOC_000018"; transcript_id "TCONS_00001260"; exon_number "2"; oId "CUFF.68.1"; class_code "u"; tss_id "TSS40";
chr1 Cufflinks exon 21156530 21156632 . + . gene_id "XLOC_000028"; transcript_id "TCONS_00002433"; exon_number "1"; oId "CUFF.88.1"; class_code "u"; tss_id "TSS69";
EDIT: Meh. Figured it out. Thanks for the help everyone.
a,b,c = 'foo bar'.split(' ',2)blah blah blah. Its not part of the code right?