Python: Line Split Value Error?
<p>I am using Python 2.7.3 btw</p>

<p>Hi all,</p>

<p>I have a little problem. The problem is that I keep running into trouble with the starred line below. (Sorry, kinda new to Python)</p>

<p>So here is my code so far:</p>

<pre><code>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
</code></pre>

<p>I keep getting this error:</p>

<pre><code>Traceback (most recent call last):
  File "parse.py", line 11, in &lt;module&gt;
    chrom,cuff,exon,start,end,dot,sign,dots,gene,tranid,exonid,rest = line.split('\t',11)
ValueError: need more than 9 values to unpack
</code></pre>

<p>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.</p>

<p>EDIT: here is a portion of the file:</p>

<pre><code>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";
</code></pre>

<p>EDIT: Meh. Figured it out. Thanks for the help everyone.</p>
