Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Exporting specific entries from huge TXT file

Does anyone know how to export specific entries from a huge txt file?
For example, I want to export each line to another txt file if they do not include hotmail, gmail, etc
I can do this in excel but there a too many lines for excel to handle so I want to export to a new txt file and manage it from there.
If you can manage it in Excel but the text file is too large, why not split the text file?
[Image: vp6iypF.gif]
Read chunks of the file at a given time. Read each line and detect if it contains keywords. Easy stuff. If you want to learn how to do that, head over to the Python section for further assistance.

PHP Code

<?php 
def read_in_chunks
(file_object, chunk_size=1024):
    
"""Lazy function (generator) to read a file piece by piece.
    Default chunk size: 1k."""
    
while True:
        
data = file_object.read(chunk_size)
        if 
not data:
            break
        yield 
data


f 
= open('really_big_file.dat')
for 
piece in read_in_chunks(f):
    
process_data(piece) 
(Aug 14, 2019 07:06 PM)datguy.dev Wrote:  Read chunks of the file at a given time. Read each line and detect if it contains keywords. Easy stuff. If you want to learn how to do that, head over to the Python section for further assistance.

Good solution! I was expecting to use PowerShell but Python will do just fine.
Linux command line can do this:

grep -v -i hotmail list.file > withouthotmail.list
or something like:
grep -v -i 'hotmail|gmail|yahoo' > noemails.list


Possibly Related Threads...
Thread / Author Replies Views Last Post
by IrlaAug 21, 2017 04:32 PM 0 86 Aug 21, 2017 04:32 PM
Last Post: Irla
by hack3rconMar 11, 2017 07:43 AM 6 170 Mar 11, 2017 07:43 AM
Last Post: hack3rcon
by hack3rconFeb 26, 2017 07:06 AM 11 248 Feb 26, 2017 07:06 AM
Last Post: Praet0rian