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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:07:59+00:00 2026-06-13T07:07:59+00:00

This is a derivative from this question . In that one, the following line

  • 0

This is a derivative from this question. In that one, the following line comes up in a pythonscript:

c1,c2 = [float(x) for x in line.split()] #convert line into 2 floats and unpack

when reading a data file with two columns.

Now, my real data file has 31 columns and I need to use columns 28 and 31 instead of 1 and 2. When I try the simplest (and ugliest) approach at escalating that line:

c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31 = [float(x) for x in line.split()]

I get the error:

ValueError: too many values to unpack

How can I properly read all the columns in my file?

  • 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-13T07:08:00+00:00Added an answer on June 13, 2026 at 7:08 am

    Another approach:

    cols = [float(x) for x in line.split()]
    c28, c31 = cols[27], cols[30]
    

    So, the overall setup will look something like:

    with open('<file name here>') as source_file:
        for line in source_file:
            cols = [float(x) for x in line.split()]
            c28, c31 = cols[27], cols[30]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is a derivative of a previous question: How to version resources that
Following on from this question regarding calculating a member I have 2 calculated members
This question is a derivative of this one: Creating XNA AudioEngine on windows game
This is a derivative question of a question I have posted here: In App
This is really derivative of my earlier question today . I created a Stored
This question is a derivation from another question in this forum which I thought
I trying to create new class object that derivative from TextBox - If there
Does PowerShell have an equivalent to this command construct from sh (and derivatives): $
I found this interesting site, that helps me understand derivatives, http://www.numberempire.com/derivatives.php , It seems
I guess no one will have a definative answer to this but considered predictions

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.