lucio 2 Posted January 28, 2014 Report Share Posted January 28, 2014 Good morning guys, sorry to bother you but I'm facing quite a few problems trying to compare table cells from 2 different csv database.this is the situation: the first database contains all the products for an ecommerce website. because a single product can be found in different sub-categories and the subcategories are missing from the main database, I had to create a new database which contains only the subcategories (in the first column) and the product number (in the second column).what the bot should do is: 1) check 2 cells value (the products numbers);2) if the value is the same, add the value from the subcategories table to a new row, else, check the next product id, and so on. This is the code: clear table(&datafeed) clear table(&categories) create table from file("C:\\Users\\luciano\\Desktop\\datafeed ubot\\datafeed.csv", &datafeed) create table from file("C:\\Users\\luciano\\Desktop\\datafeed ubot\\categories db.csv", &categories) set(#row position product id datafeed, 1, "Global") set(#row position category, 1, "Global") set(#row position product id, 1, "Global") set(#product id datafeed position, 1, "Global") set(#current category position, 1, "Global") set(#product id category position, 1, "Global") set(#product id datafeed position value, $table cell(&datafeed, #row position product id datafeed, 0), "Global") set(#current category position value, $table cell(&categories, #row position category, 0), "Global") set(#product id category position value, $table cell(&categories, #row position product id, 1), "Global") loop($table total rows(&datafeed)) { if($comparison(#current category position value, "=", #product id datafeed position value)) { then { set table cell(&datafeed, #row position, 19, #current category position value) } else { } } increment(#product id datafeed position) increment(#row position) if($comparison(#current category position value, "=", #product id datafeed position value)) { then { set table cell(&datafeed, #row position, 19, #current category position value) } else { increment(#current category position) increment(#product id category position) } } } save to file("C:\\Users\\luciano\\Desktop\\db.csv", &datafeed) Do you have any suggestions? Thanks in advance, Lucio Quote Link to post Share on other sites
lucio 2 Posted January 28, 2014 Author Report Share Posted January 28, 2014 I tried with this code too, but same results:clear table(&datafeed) clear table(&categories) create table from file("C:\\Users\\luciano\\Desktop\\datafeed ubot\\datafeed.csv", &datafeed) create table from file("C:\\Users\\luciano\\Desktop\\datafeed ubot\\categories db.csv", &categories) add list to list($plugin function("TableCommands.dll", "$list from table", &datafeed, "Column", 0), %product id datafeed, "Don\'t Delete", "Global") add list to list($plugin function("TableCommands.dll", "$list from table", &categories, "Column", 1), %product id category, "Don\'t Delete", "Global") add list to list($plugin function("TableCommands.dll", "$list from table", &categories, "Column", 0), %categories, "Don\'t Delete", "Global") set(#row position, 1, "Global") set(#product id datafeed position, 1, "Global") set(#current category position, 1, "Global") set(#product id category position, 1, "Global") set(#product id datafeed position value, $next list item(%product id datafeed), "Global") set(#current category position value, $next list item(%categories), "Global") set(#product id category position value, $next list item(%product id category), "Global") loop($list total(%product id datafeed)) { if($comparison(#current category position value, "=", #product id datafeed position value)) { then { set table cell(&datafeed, #row position, 19, #current category position value) } else { } } increment(#product id datafeed position) increment(#row position) if($comparison(#current category position value, "=", #product id datafeed position value)) { then { set table cell(&datafeed, #row position, 19, #current category position value) } else { increment(#current category position) increment(#product id category position) } } } save to file("C:\\Users\\luciano\\Desktop\\db.csv", &datafeed) Quote Link to post Share on other sites
UBotDev 276 Posted January 28, 2014 Report Share Posted January 28, 2014 I tried with this code too, but same results: clear table(&datafeed) clear table(&categories) create table from file("C:\\Users\\luciano\\Desktop\\datafeed ubot\\datafeed.csv", &datafeed) create table from file("C:\\Users\\luciano\\Desktop\\datafeed ubot\\categories db.csv", &categories) add list to list($plugin function("TableCommands.dll", "$list from table", &datafeed, "Column", 0), %product id datafeed, "Don\'t Delete", "Global") add list to list($plugin function("TableCommands.dll", "$list from table", &categories, "Column", 1), %product id category, "Don\'t Delete", "Global") add list to list($plugin function("TableCommands.dll", "$list from table", &categories, "Column", 0), %categories, "Don\'t Delete", "Global") set(#row position, 1, "Global") set(#product id datafeed position, 1, "Global") set(#current category position, 1, "Global") set(#product id category position, 1, "Global") set(#product id datafeed position value, $next list item(%product id datafeed), "Global") set(#current category position value, $next list item(%categories), "Global") set(#product id category position value, $next list item(%product id category), "Global") loop($list total(%product id datafeed)) { if($comparison(#current category position value, "=", #product id datafeed position value)) { then { set table cell(&datafeed, #row position, 19, #current category position value) } else { } } increment(#product id datafeed position) increment(#row position) if($comparison(#current category position value, "=", #product id datafeed position value)) { then { set table cell(&datafeed, #row position, 19, #current category position value) } else { increment(#current category position) increment(#product id category position) } } } save to file("C:\\Users\\luciano\\Desktop\\db.csv", &datafeed) By quickly throwing an eye on your code I see that you are using the lists the wrong way. 1st list parameter is list name, and 2nd list parameter is the data you want to load from a list (not the other way around). Quote Link to post Share on other sites
lucio 2 Posted January 28, 2014 Author Report Share Posted January 28, 2014 ops...haven't noticed that!thanks for the heads up! unfortunately i still can't get it to work... Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted January 28, 2014 Report Share Posted January 28, 2014 Lucio, Can you give examples of your 2 DB's and then what it should look like at the end? Like: Product numbers DB6540654634065463654654460746546440 Categories DB PhonesCell PhonesCell phone accesseriesIphonesBlackberry's New DB ? Maybe you upload them.next to post button is "more reply options" button to attach files. Or id you are editing a post you made it would be "use full editor" Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted January 28, 2014 Report Share Posted January 28, 2014 Lucio, Here's a couple examples. The second one is probably closer to what you want. Without knowing what your categories DB looks like I'm just guessing. You can check these out and hopefully work off of these examples. Example 1 set(#prod IDs, "1558122555", "Global")set(#category list, "1544800555900018669", "Global")clear list(%exist in category)clear list(%category list)clear list(%prod IDs)add list to list(%prod IDs, $list from text(#prod IDs, $new line), "Delete", "Global")add list to list(%category list, $list from text(#category list, $new line), "Delete", "Global")loop($list total(%prod IDs)) { set(#prod next item, $next list item(%prod IDs), "Global") set(#prod exist in category, $plugin function("File Management.dll", "$exists in list", %category list, #prod next item), "Global") if(#prod exist in category) { then { add item to list(%exist in category, #prod next item, "Delete", "Global") } else { } }} Example 2 set(#prod IDs, "1558122555", "Global")set(#category list, "Phones,Iphones,Blackberry\'s,Windows Phone15,800,33,44,6944,9000,15,9000,555800,122,15,555,186555,444,555,888,9999000,58,69,122,111186,400,300,600,5869,58,900,992,449", "Global")if($file exists("{$special folder("Desktop")}\\demo table.csv")) { then { } else { save to file("{$special folder("Desktop")}\\demo table.csv", #category list) }}clear list(%exist in category)clear list(%category list)clear list(%prod IDs)add list to list(%prod IDs, $list from text(#prod IDs, $new line), "Delete", "Global")add list to list(%category list, $list from text(#category list, $new line), "Delete", "Global")clear table(&categories)create table from file("{$special folder("Desktop")}\\demo table.csv", &categories)loop($list total(%prod IDs)) { set(#prod next item, $next list item(%prod IDs), "Global") set(#category index, "-1", "Global") loop($table total columns(&categories)) { increment(#category index) set(#category, $table cell(&categories, 0, #category index), "Global") clear list(%column) add list to list(%column, $plugin function("TableCommands.dll", "$list from table", &categories, "Column", #category index), "Delete", "Global") set(#prod exist in category, $plugin function("File Management.dll", "$exists in list", %column, #prod next item), "Global") if(#prod exist in category) { then { add item to list(%exist in category, "{#prod next item},{#category}", "Delete", "Global") } else { } } }} make sure you have plugins installed and activated. Your table delimiter may be different too. US is a coma and Europe is semicolon. TCluciono examples.ubot Quote Link to post Share on other sites
lucio 2 Posted January 29, 2014 Author Report Share Posted January 29, 2014 Traffik Cop, first of all thanks for your help and i apologize if i couldn't reply sooner. i'm attaching the first 50 rows of both databases. I'm going to test your examples asap. thanks in advance for your time, Luciodatafeed test.csvcategories db test.csv Quote Link to post Share on other sites
k1lv9h 76 Posted January 29, 2014 Report Share Posted January 29, 2014 Hi, Sample code:sample-table-003.ubot Kevin 1 Quote Link to post Share on other sites
lucio 2 Posted January 29, 2014 Author Report Share Posted January 29, 2014 Kevin I have no word: thank you so much for helping me! I owe you a big one! 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.