1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HOW-TO Extract Lines from File A that Contains Words in File B?

Discussion in 'BlackHat Lounge' started by TrailBlazer, Jan 3, 2015.

  1. TrailBlazer

    TrailBlazer Junior Member

    Joined:
    Aug 11, 2012
    Messages:
    170
    Likes Received:
    51
    I have a large text file, over 1gb large containing data line by line. This is text file A.txt


    I then have the second file, text file B.txt that contains 30,000 unique words that I want to extract from text file A, along with the rest of the line where the word is found in text file A.


    An example of this is:


    --Text File A--


    dog in house
    cat at school
    kid in playground
    tom at oaks
    so much stuff
    inhouse cool stuff


    --Text File B--


    house
    oaks


    --Result File Output--


    dog in house
    tom at oaks
    inhouse cool stuff




    How would I go about doing this that would work the fastest way possible? Is there any software on the market for purchase that specializes in this type of task?
     
  2. divok

    divok Senior Member

    Joined:
    Jul 21, 2010
    Messages:
    1,063
    Likes Received:
    645
    Location:
    .IN
    you would need a custom script for this.
    you could do this in npp easily but I doubt that with size of your files .

    let me know If you can't find a solution , i might help you out with a python script.