Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8692173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:16:02+00:00 2026-06-13T00:16:02+00:00

I am using Python 2.7.3 btw Hi all, I have a little problem. The

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:16:04+00:00Added an answer on June 13, 2026 at 12:16 am

    To see what the exact line number where the error is do this:

    for i, line in enumerate(filein):
        try:
            chrom,cuff,exon,start,end,dot,sign,dots,gene,tranid,exonid,rest = line.split('\t',11)
        except ValueError:
            print "ValueError on line", i+1
            print "line", repr(line)
            raise
    

    In your comment you provided a link to your text file. I don’t find any line with less than 11 tabs:

    >>> for i, line in enumerate(urllib.urlopen('http://dl.dropbox.com/u/108419362/file.gtf')):
    ...     if line.count('\t') < 11:
    ...         print i+1, repr(line)
    ...         break
    ...
    >>>
    

    Double check that you are really opening the file you think you are opening.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Python I need to insert a newline character into a string every 64
Using Python I need to delete all characters in a multiline string up to
I'm using Python 2.6, and I have two datasets, each being a list of
I need to convert string into ASCII code. I'm using python. I did as
My big problem here is that I'm 1 day into learning MacOSX so the
Using Python's csv module, is it possible to read an entire, large, csv file
Using Python how do you reduce a list of lists by an ordered subset
Using Python, I want to know whether Java is installed.
Using Python module re, how to get the equivalent of the \w (which matches
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.