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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:20:52+00:00 2026-06-15T08:20:52+00:00

So, I have this file that has data set up like this: Bob 5

  • 0

So, I have this file that has data set up like this:

Bob 5 60
Carl 7 80
Rick 8 100
Santiago 7 30

I need to separate each part into three different lists. One for the name, one for the first number, and one for the second number.

But I don’t really understand, how exactly do I extract those parts? Also, let’s say I want to make a tuple with the first line, with each of the different parts (the name, first number, and second number) into a single tuple?

I just don’t get how I extract that information.
I just learned how to read and write text files…so I’m pretty clueless.

EDIT: As a note, the text file already exists. The program I’m working on needs to read the text file, which has its data formatted in the way I listed.

  • 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-15T08:20:54+00:00Added an answer on June 15, 2026 at 8:20 am

    You can split each line on whitespace:

    with open(yourfile) as f:
        rows = [l.split() for l in f]
    
    names, firstnums, secondnums = zip(*rows)
    

    zip(*iterable) re-arranges the 3 columns into 3 lists.

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

Sidebar

Related Questions

I have an XML file that contains one set of data and this has
I have a file that has columns that look like this: Column1,Column2,Column3,Column4,Column5,Column6 1,2,3,4,5,6 1,2,3,4,5,6
I have a data set that looks something like this: ID | ItemName |
This has been killing me - I have a massive file that I need
I have created an arff file for a data set that I would like
I have a file that looks something like this: ABC DEF GHI I have
I have a file that contain lines that looks like this: >AF001546_1 [88 -
I have a data object (let's say it's called 'Entry') that has a set
I have data that is organized in panels like this (see below for output
I have a .txt file that has a bunch of formatted data in it

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.