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

  • SEARCH
  • Home
  • 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 6123033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:58:06+00:00 2026-05-23T15:58:06+00:00

I have a large tab delimited text file, for example, call it john_file: 1

  • 0

I have a large tab delimited text file, for example, call it john_file:

1 john1 23 54 54
2 john2 34 45 66
3 john3 35 43 54
4 john2 34 54 78

5 john1 12 34 65
6 john3 34 55 66

What’s a quick way to parse this file into 3 lists based on name(john1, 2 or 3)?

fh=open('john_file.txt','r').readlines()
john1_list=[]
for i in fh:
 if i.split('\t')[1] == "john1":
  john1_list.append(i)

Thanks in advance

  • 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-23T15:58:06+00:00Added an answer on May 23, 2026 at 3:58 pm
    from collections import defaultdict
    
    d = defaultdict(list)
    
    with open('john_file.txt') as f:
        for line in f:
            fields = line.split('\t')
            d[fields[1]].append(line)
    

    The individual lists are then in d['john1'], d['john2'] etc

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

Sidebar

Related Questions

I have a tab-delimited text file that is very large. Many lines in the
I have a text file with a large amount of data which is tab
I have a large file named CHECKME which is tab delimited. There are 8
I have been able to extract certain lines from a large tab-separated text file
I have many large (~30 MB a piece) tab-delimited text files with variable-width lines.
I have a large text file I need to sort in Java. The format
I'm iterating through a very large tab-delimited file (containing millions of lines) and pairing
I have a large file (100 million lines of tab separated values - about
I have a large space-indented file. I replaced the spaces with tabs by way
Background: I'm cleaning large (cannot be held in memory) tab-delimited files. As I clean

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.