Jump to content
Sign in to follow this  
dil_bert

filter out certain lines of a big data-set

Recommended Posts

hello dear folks - good day dear php-experts,

 

 

i have some lines of data - approximately 500 lines  - within this set of data i have some lines i want to filter out... - each line where the marker word "span" is contained:

'url': 'http:www.url1.com', 'the_firstname': 'Pope', 'lastname': 'of Rome', 'the email-adress': 'popeofrome@hotmail.com'
'url': 'http:www.url2.org', 'the_firstname': 'Ben', 'lastname': 'hur', 'the email-adress': 'ben@hotmail.com'
'url': 'http:www.url3.net', 'the_firstname': 'Ali', 'lastname': 'the champ', 'the email-adress': 'ali-thechamp0hotmail.de'
'url': 'http:www.url4.at', 'the_firstname': 'meetoo', 'lastname': 'youtoo', 'the email-adress': 'meetoo@hotmail.com'


'url': 'http:www.url5.at', 'the_firstname': 'spam', 'lastname': 'spam', 'the email-adress': 'spamadress@hotmail.com'

how to do that - how can i filter out each line which contains the word  spam?

 

 

Is there an appropiate way?

Share this post


Link to post
Share on other sites

From the CLI, grep -v spam yourdata.txt would work, assuming no false positive matches against 'spam'

 

If you want to do it with PHP then load the data with file_get_contents and loop over it filtering out lines by matching with something like strpos, preg_match, etc.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.