Jump to content
UBot Underground

saving data to a csv file


Recommended Posts

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

Link to post
Share on other sites

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...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...