dsc76 6 Posted August 13, 2011 Report Share Posted August 13, 2011 Hello, I have a .txt file of accounts (email addresses) with one on each line and want to remove / delete an account from the text file if suspended. For example “if suspended then delete from .txt file†but I am having trouble figuring out how to delete the account from the .txt file. Any advice is appreciated. Thanks! Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted August 13, 2011 Report Share Posted August 13, 2011 add to list (list from file) loop (list total) if (suspended)remove from list Save list to new txt filewill have the new formed list without the accounts that were removed from being suspended. Quote Link to post Share on other sites
dsc76 6 Posted August 13, 2011 Author Report Share Posted August 13, 2011 Hi, Thanks for the feedback but the "if (suspended)remove from list" command is what I'm having trouble figuring out. What command do I use to delete the current list item from the list? Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted August 13, 2011 Report Share Posted August 13, 2011 Hi, Thanks for the feedback but the "if (suspended)remove from list" command is what I'm having trouble figuring out. What command do I use to delete the current list item from the list? see attached.remove from list-lowridertj.ubot Quote Link to post Share on other sites
dsc76 6 Posted August 13, 2011 Author Report Share Posted August 13, 2011 Thanks! I'll test and follow up. Quote Link to post Share on other sites
JohnB 255 Posted August 13, 2011 Report Share Posted August 13, 2011 There is a little trick you need to implement when removing from a list where the number of loop cycles is the list total. The reason is this...when you remove a "list position" the next list position becomes that list position. For example, you remove position #5...now position #6 becomes position #5 but the loop has already processed that position # so it goes on to #6 (which is really the original #7)...make sense? So I do it like this: set--->#position=0 (outside the loop) nav, do stuff, find one that needs to be removed, remove it, DECREMENT #position, and then INCREMENT it. Now it will re-do the same list position which is actually the next list item. And it won't error over the number of cycles (actually, you may not get an error, but it will skip list items if any are removed) I hope that makes sense. John Note the decrement and increment go inside the THEN node in the conditional statement (yes, both of them) You also need just an increment at the end of the loop in case the condition is not met (you don't remove it from the list). I uploaded an example way back. Here it is:remove_from_list.ubot 1 Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted August 13, 2011 Report Share Posted August 13, 2011 opps you are correct my mistake. +1 John Quote Link to post Share on other sites
JohnB 255 Posted August 13, 2011 Report Share Posted August 13, 2011 It's just something that doesn't naturally make sense at first (because decrementing position 0 seems unnatural), but when you see it work, you're like.."Oh, I see now!" (That was my reaction when I first got that working way back)...When you think about it out loud, it makes perfect sense. Quote Link to post Share on other sites
JohnB 255 Posted August 13, 2011 Report Share Posted August 13, 2011 I just had a conversation with Eddie who exposed an easier way to do this. If you loop through the list from the bottom you don't have these confusing issues. You do this by setting the #position to $list total and decrementing. No other conditions for this process. here is the version showing this:remove_from_list_easier.ubot Quote Link to post Share on other sites
dsc76 6 Posted September 29, 2011 Author Report Share Posted September 29, 2011 Thanks for the feedback guys but I am still completely lost on this one. It just seems like a huge process just to remove a suspended email from a list. I can't seem to work your example in to my application. Please see the attached screen shot of what I have so far. Thanks again. I have it working but not sure if this is a good way to do it or not. Thanks.Update: Disregard guys I think I got it working Thanks! Quote Link to post Share on other sites
earthlingj 13 Posted December 23, 2012 Report Share Posted December 23, 2012 wont this not work though if you are using multi threads? lets say you got 5 threads running... and 1 account is suspended so you remove item and then decrement.. but by that point the other threads have already pulled different accounts. Wouldnt that mess up the order? 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.