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 6136319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:35:19+00:00 2026-05-23T17:35:19+00:00

I have a code meant to strim a string within a large text file.

  • 0

I have a code meant to strim a string within a large text file. When I run it an error message shows up “ValueError: need more than 1 value to unpack”. So I changed the integer for 0, 1 and 2 in this line :

    _, k = line.split('\t',1)

If I input 2 it says ‘Too many value to unpack’. I tried to define each variable as follow :

    f = []
    _ = []
    k = []
    x = []
    i = 0

.. That didn’t work out either.

Here is the code:

    # Opens each file to read/modify
    infile='110331_HS1A_1_rtTA.result'
    outfile='2.txt'

    #import Regex
    import re

    with open (infile, mode='r', buffering=-1) as in_f, open (outfile, mode='w', buffering=-1) as out_f:
        f = (i for i in in_f if i.rstrip())
        for line in f:
            _, k = line.split('\t',1)
            x = re.findall(r'^1..100\t([+-])chr(\d+):(\d+)\.\.(\d+).+$',k)
            if not x:
                continue
            out_f.write(' '.join(x[0]) + '\n')

Here is the error :

   Traceback (most recent call last):
     File "C:\DB\Stack Overflow\test5.py", line 11, in <module>
       _, k = line.split('\t',1)
   ValueError: need more than 1 value to unpack

Thanks for those who are willing to help/teach me 🙂

  • 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-05-23T17:35:20+00:00Added an answer on May 23, 2026 at 5:35 pm

    Oh, that’s the code I wrote on the other question. You could have asked there…

    Since the file you gave didn’t had any non-empty lines without tab, i assumed there would be no problem.

    You can check if there’s any tab character in the line by changing this one:

    f = (i for i in in_f if i.rstrip())
    

    to

    f = (i for i in in_f if '\t' in i.rstrip())
    

    So you’ll remove empty lines and also those without the '\t'.
    To see the line of your file having that problem, you can do (using the original code):

    try:
        _, k = line.split('\t',1)
    except:
        print(line)
    

    BTW, the _ is often used to things we don’t care in some operation. It can have any name.

    ATCGATTTCG....ATGC    1..100blablabla
           ^                     ^
     useless part (_)     important one (k)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code I have pasted below is meant to display images on the middle
I have code that references a web service, and I'd like the address of
I have code to create another row (div with inputs) on a button click.
I have code similar to this filtering entries in an Array of Objects: var
I have code like this: var newMsg = new Msg { Var1 = var1,
I have code like this: template <typename T, typename U> struct MyStruct { T
I have code similar to the following in many places: var dbParams = db.ReadParams(memberID,
I have code like this to move the player in my game left, right,
I have code that looks like the following, which works fine for displaying the
I have code in an Update Panel and even though on a button click

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.