awesome sauce 0 Posted February 10, 2016 Report Share Posted February 10, 2016 I'm scraping a website that when I scrape the email addresses they have 'mailto:' at the start. What I would like to do is remove 'mailto:' so I just have the address. The email addresses are currently stored in a list. Here's the code I have, but it's not doing anything. I can't quite figure it out because I can't use replace with the if statement. Any suggestions? define Clean Business Data { loop($list total(%email_address)) { set(#email_row,$next list item(%email_address),"Global") set(#email_row_clean,$replace(#email_row,"mailto:",""),"Global") } } Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted February 10, 2016 Report Share Posted February 10, 2016 Hello, Try something like this clear list(%a) clear list(%clean) add list to list(%a,$list from text("mail to: lkfjlsdkjf lskjlfj s ljf alkjdf mail to: what evva mail to: mail sub mail to: mail body mail to: some text",$new line),"Delete","Global") add list to list(%clean,$list from text($replace(%a,"mail to: ",$nothing),$new line),"Delete","Global") alert(%clean) HTHelps,CD Quote Link to post Share on other sites
awesome sauce 0 Posted February 10, 2016 Author Report Share Posted February 10, 2016 That helped me be able to remove mailto:, however it's removing my blank values from my first list. Example:%email_address has 118 values, some of which are filled with $nothing because there isn't an email for that. %email_address_clean then only has 44 items and has removed all the lines with $nothing. Is it possible to use replace but keep the $nothing values intact? (then I should have 118 items in my list, even though I just have 44 email addresses) Here is the code I'm using to remove mailto: define Clean Business Data { loop($list total(%email_address)) { add list to list(%email_address_clean,$list from text($replace(%email_address,"mailto:",$nothing),$new line),"Delete","Global") } } Quote Link to post Share on other sites
deliter 203 Posted February 10, 2016 Report Share Posted February 10, 2016 the problem their is your new list email_address_clean is deleting duplicates,so change that to dont delete and it will work 1 Quote Link to post Share on other sites
awesome sauce 0 Posted February 15, 2016 Author Report Share Posted February 15, 2016 Alright, so I changed the list so it doesn't delete duplicates. However, for some reason everything is being duplicated... a lot. Out of less than 52 items, the following code returned 1144 emails (many duplicated and the blank lines aren't there). define Clean Business Data { clear list(%email_address_clean) loop($list total(%email_address)) { add list to list(%email_address_clean,$list from text($replace(%email_address,"mailto:",$nothing),$new line),"Don\'t Delete","Global") } } Quote Link to post Share on other sites
HelloInsomnia 1103 Posted February 15, 2016 Report Share Posted February 15, 2016 You are looping for the list total of the email addresses and then adding the second list into it multiple times, that is an issue. Instead try this: define Clean Business Data { clear list(%email_address_clean) add list to list(%email_address_clean,$list from text($replace(%email_address,"mailto:",$nothing),$new line),"Don\'t Delete","Global") } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.