jomark3 25 Posted October 12, 2012 Report Share Posted October 12, 2012 I'm scraping a page of data containg 40 rows of data with 20 columns each (see attached bot). How do I save this data to a csv file so that each cell contains a single data item. Currently, the data in cell a1, contains all 20 data items for that row, the data in cell b1, contains all 20 data items for that row, etc. how do I create a csv file so that each cell contains a single data item.football.ubot Quote Link to post Share on other sites
VaultBoss 310 Posted October 12, 2012 Report Share Posted October 12, 2012 I think this should work, but DO test it... loop(1) { navigate("http://www.nfl.com/standings?category=league", "Wait") scrape table(<tagname="td">, &_tbl_Scraped) set(#var_Loops, $table total rows(&_tbl_Scraped), "Global") set(#var_Loops, $subtract(#var_Loops, 4), "Global") set(#var_Loop, 0, "Global") clear table(&_tbl_Results) loop(#var_Loops) { set(#var_ColNo, 0, "Global") clear list(%lst_ScrapedTeam) loop($table total columns(&_tbl_Scraped)) { set(#var_Item, $table cell(&_tbl_Scraped, $add(#var_Loop, 2), #var_ColNo), "Global") add item to list(%lst_ScrapedTeam, #var_Item, "Don\'t Delete", "Global") increment(#var_ColNo) } add list to table as row(&_tbl_Results, #var_Loop, 0, %lst_ScrapedTeam) increment(#var_Loop) } save to file("{$special folder("Application")}/new data.csv", &_tbl_Results) } . Of course, you can use a define command to replace the main loop there... Quote Link to post Share on other sites
k1lv9h 76 Posted October 13, 2012 Report Share Posted October 13, 2012 Hi, Sample code:football-001.ubot Kevin Quote Link to post Share on other sites
jomark3 25 Posted October 13, 2012 Author Report Share Posted October 13, 2012 Hi, Sample code:football-001.ubot Kevin Thanks alot Kevin, Works Perfectly!! Quote Link to post Share on other sites
jomark3 25 Posted October 13, 2012 Author Report Share Posted October 13, 2012 Thanks all for spending some time to help solve my problem. Willywonka & VaultBoss - The standard version does not allow the 'scrape table' command. Quote Link to post Share on other sites
jomark3 25 Posted October 14, 2012 Author Report Share Posted October 14, 2012 Wow, to sad to hear that. This is a basic option and should be on all versions of the software. I agree! 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.