Chainsaw 9 Posted October 15, 2013 Report Share Posted October 15, 2013 I've got some huge text files of data, too large to simply import as a table. So instead I'd like to read just one line from the file, do something with the data and then delete that one line. Rinse and repeat. Reading the entire file is out too, so ideally I'd like to read just the first or last line of the file. Any suggestions welcome. Quote Link to post Share on other sites
Gogetta 263 Posted October 15, 2013 Report Share Posted October 15, 2013 There is no way to read one line of a file unless you read the entire file. If your file is that big break it up into chunks and use the $get files function and add the file names into a list. That way you can call them one by one for use in your bot.. 1 Quote Link to post Share on other sites
wilriv21 16 Posted October 15, 2013 Report Share Posted October 15, 2013 With huge files - any reason to not use MySQL or SQLite? UBot supports both. 1 Quote Link to post Share on other sites
Chainsaw 9 Posted October 16, 2013 Author Report Share Posted October 16, 2013 There is no way to read one line of a file unless you read the entire file. If your file is that big break it up into chunks and use the $get files function and add the file names into a list. That way you can call them one by one for use in your bot...Thanks, that is the solution I'm probably going to go with for now. Quote Link to post Share on other sites
Chainsaw 9 Posted October 16, 2013 Author Report Share Posted October 16, 2013 With huge files - any reason to not use MySQL or SQLite? UBot supports both. Tried adding the files to a SQLite database but at the moment there seems to be an issue with connecting to SQLite databases. Perhaps that will be working in 5.01? MySQL might of course work but last time I tried MySQL, I was getting a connection error as well and so haven't yet tested MySQL. Quote Link to post Share on other sites
a2mateit 395 Posted March 6, 2016 Report Share Posted March 6, 2016 With all the free and paid plugins out there nowadays is there anyway to do this yet? I need to be able to read the first line of a file, then delete that line. I've been searching around for a while now to try and find this out... TIA Quote Link to post Share on other sites
HelloInsomnia 1103 Posted March 6, 2016 Report Share Posted March 6, 2016 Well you can read the first line of the file using this: http://network.ubotstudio.com/forum/index.php/topic/15579-free-plugin-advanced-file-clipboardhandle-big-lists-in-text-files-and-more/ Not sure about deleting it though unless you add it to a list and remove that list item. Quote Link to post Share on other sites
a2mateit 395 Posted March 6, 2016 Report Share Posted March 6, 2016 Well you can read the first line of the file using this: http://network.ubotstudio.com/forum/index.php/topic/15579-free-plugin-advanced-file-clipboardhandle-big-lists-in-text-files-and-more/ Not sure about deleting it though unless you add it to a list and remove that list item. Thanks Nick. Currently what I'm doing is loading it to a list, then removing the first list item, then resaving. But when the list has 50k lines, this really slows things down. 1 Quote Link to post Share on other sites
HelloInsomnia 1103 Posted March 6, 2016 Report Share Posted March 6, 2016 Thanks Nick. Currently what I'm doing is loading it to a list, then removing the first list item, then resaving. But when the list has 50k lines, this really slows things down. Why do you need to delete the line after reading it? In the end you would end up with a blank text file. Instead you can just save the last line number read if the bot doesn't do them all at once or in case it crashes or something. Quote Link to post Share on other sites
a2mateit 395 Posted March 6, 2016 Report Share Posted March 6, 2016 Why do you need to delete the line after reading it? In the end you would end up with a blank text file. Instead you can just save the last line number read if the bot doesn't do them all at once or in case it crashes or something. That's the whole idea. I'm cleaning one scrape file, and if it's successful it gets appended to a different list. So the blank text file will is ok in this instance. But I see what your saying about just saving the list position each time it runs and recalling it if there's a crash. Quote Link to post Share on other sites
LordPorker 7 Posted June 22, 2016 Report Share Posted June 22, 2016 Kinda stumped with this too; why can't UB simply take a line (even better, would be a choice to select a random one), directly from a file, then once it's taken, delete it? Saving a large file into UB must take a toll on resources, no? Anyway, so I've saved the file into UB using: add list to list with list from file. Now that I have my (virtual) list, I need to take a url and then delete it. Can anyone explain the process? Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted June 22, 2016 Report Share Posted June 22, 2016 Hey LP,the large data plugin or advance file plugin will handle this and you wont have to delete just cycle thru with an index. Start at zero(set #index 0, outside loop) and then inside the loop increment the #index. or what you asked specificallyuse remove list item 0 everytimethen instead of $next list item use $list item and 0 everytime so in affect you are deleting the first item and the next rolls to position 0 which will be the next. CD Quote Link to post Share on other sites
LordPorker 7 Posted June 22, 2016 Report Share Posted June 22, 2016 I kinda follow you, but the issue is that I'm taking a random url from an actual file. If I delete position 0, then the random url is still in the text file. So far at the moment, I've managed to grab a random line from a list using this: set(#listing,$random list item($list from file("C:random.txt")),"Global") The next issue is deleting said line from the list, ideally using a variable search for and to delete the line. Quote Link to post Share on other sites
abbas786 78 Posted June 22, 2016 Report Share Posted June 22, 2016 Hey Tony, Try this logic Set #TotalRecords = List TotalSet #RandomRecord = $Rand(1, #TotalRecords ) Now Select ur item from listset(#listing,$random list item(#RandomRecord),"Global")and than Delete it Hope it helps Quote Link to post Share on other sites
bangali_beta 11 Posted June 26, 2016 Report Share Posted June 26, 2016 Chainsaw, Can you not dump the file data onto a list ($list from file) and then grab the $List Item: 0 and put it into a 2nd list and then use the "Remove From List" command to remove $List Item: 0 from the 1st list and so on ? Quote Link to post Share on other sites
LordPorker 7 Posted June 26, 2016 Report Share Posted June 26, 2016 Hey Tony, Try this logic Set #TotalRecords = List TotalSet #RandomRecord = $Rand(1, #TotalRecords ) Now Select ur item from listset(#listing,$random list item(#RandomRecord),"Global") and than Delete it Hope it helps Thanks, but my issue is working directly with a text file (not UB's virtual list). I need to delete an item from an actual .txt file. Tried it with remove from file, but no luck there (as this command is only meant for UB's own list). Why can't we work directly with a txt. file? It's a joke, as getting an item from a list, and then deleting it directly, is a basic function in programming, lol. Oh well. Quote Link to post Share on other sites
bangali_beta 11 Posted June 27, 2016 Report Share Posted June 27, 2016 Thanks, but my issue is working directly with a text file (not UB's virtual list). I need to delete an item from an actual .txt file. Tried it with remove from file, but no luck there (as this command is only meant for UB's own list). Why can't we work directly with a txt. file? It's a joke, as getting an item from a list, and then deleting it directly, is a basic function in programming, lol. Oh well. Correct. It's a joke having to deal with $Lists in the middle. I suggest you suggest a feature to deal with the file. Maybe the following functions would be good so suggest them to the Ubot feature suggestion section:$file$delete from file$Add To Line Number "so" In File$Delete From Line Number "so" In File$Replace From Line Number "so" To "so" In FileAnd so on. 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.