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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:08:00+00:00 2026-05-26T06:08:00+00:00

i am trying to grab some lines form lines in a huge file. For

  • 0

i am trying to grab some lines form lines in a huge file. For example suppose
f =

a b
c d
e s
m n
h g
.
.
.

The code I am trying to used is as follows

import re
f = open('f.txt')
y = [a,s, ...] # the laters that i would like to grab it with the line form the file f
grab = y
for line in f:
    match = grab.search(line)
    if match: 
        print match.group()
  • 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-26T06:08:01+00:00Added an answer on May 26, 2026 at 6:08 am

    With the following code you will print lines from f if any of the chars in y is in the line.
    You can modify it easily if what you want is to get lines where both chars are in y

    for line in f:
        letters = line.split()
        for letter in letters:
           if letter in y:
               print line
               break
    

    btw, do not forget to close your open file or better to use with as .

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

Sidebar

Related Questions

I'm trying to grab some information from a private XML file used as DB
I am trying to write a code that will grab some information provided by
I am currently trying to grab some rows from a SQL Server database using
I'm trying to grab some JSON from Apple's iTunes JSON service. The request is
I have been playing around with NSURLConnection. Now I'm trying to grab some data
I am trying to grab a visual force element using jQuery and having some
I'm trying to grab a div's ID in the code behind (C#) and set
I was trying to grab some data from the database using JQuery AJAx, and
I'm trying to parse some data out of a file using Perl & Parse::RecDescent.
hello there :) Im trying to figure out how i can grab some content

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.