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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:12:14+00:00 2026-05-15T04:12:14+00:00

I have a file with around 100k lists and have a another file with

  • 0

I have a file with around 100k lists and have a another file with again a list of around an average of 50.

I want to compare 2nd item of list in second file with the 2nd element of 1st file and repeat this for each of the 50 lists in 2nd file and get the result of all the matching element.

I have written the code for all this,but this is taking a lot of time as it need to check the whole the 100k list some 50 times. I want to improve the speed.

I cant not post my code as it is part of big code and will be difficult to infer anything from that.

  • 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-15T04:12:14+00:00Added an answer on May 15, 2026 at 4:12 am

    You can afford to read all the “lakh” (hundred thousands) lines from the first file in memory once:

    import collections
    d = collections.defaultdict(list)
    
    with open('lakhlists.txt') as f:
        for line in f:
            aslist = line.split()  # assuming whitespace separators
            d[aslist[1]].append(aslist)
    

    you don’t give us many crucial parameters but I’d bet this will fit in memory (for reasonable guesses at list lengths) on typical model platforms. Assuming this part works, just looping over the other, small files, and indexing into d should be trivial in comparison;-)

    If you care to express your specs, and the relevant numbers, more precisely (and ideally in English), maybe more specific help can be offered!

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

Sidebar

Related Questions

I have ~15 million line file. I have another file with around 500,000 lines.
I have a large XML file ( around 1mb ) . i want to
I have a text file that is around 1.7MB that has a list of
I have a huge file (with around 200k inputs). The inputs are in the
I have a file that contains around thousands of lines. Format of every line
I have two 3GB text files, each file has around 80 million lines. And
I have an xml file with 3 pieces of data per item: productName, productCode
I have a CSV file with around 1.8million rows. I need to insert them
I have several large MyISAM tables (data file around 1.5 GB) which I need
I have read a file with around 120k words so i try to do

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.