@@ -0,0 +1,1848 @@
+#!/usr/bin/python%0A# Python module to collect data from basketball-reference.com and output the collected data in a CSV formatted file%0A%0Aimport urllib2%0Aimport argparse%0Afrom bs4 import BeautifulSoup%0Aimport csv%0Aimport re%0Aimport string%0Afrom string import Template%0A%0A# Argument parsing%0Aparser = argparse.ArgumentParser(description='Jumpball collect')%0Aparser.add_argument('-s', '--season', action='store', help='Season in year', dest=%22year_season%22, required=True)%0Aparser.add_argument('-t', '--team', action='store', help='NBA Team', dest=%22nba_team%22, required=True)%0A#args = vars(parser.parse_args())%0Aargs = parser.parse_args()%0A%0Aseason = args.year_season%0Ateam = args.nba_team%0Aprint season%0Aprint team%0A%0A%0Apage1 = urllib2.urlopen(%22http://www.nba.com/%25s/roster/%25s%22 %25 (team, season ))%0A%0Af = csv.writer(open('season_%25s_%25s_players_height.csv' %25 (season, team), 'w'))%0A%0A# CSV file header%0Af.writerow(%5B%22name%22 ,%22ht%22, %22wt%22, %22team%22%5D)%0A%0Adef getStatsFromWeb(page):%0A    content = page.read()%0A%0A    soup = BeautifulSoup(content)%0A    %0A    table = soup.find('table', summary=%22Team Roster%22)%0A#    rows = table.findAll('tr', recursive=False)%0A    rows = table.findAll('tr')%0A#    new_rows = string.replace(rows%5B0%5D, ',', '%5Cn')%0A    #new_rows = re.sub(',', '%5Cn', rows%5B0%5D)%0A    converted_rows = unicode.join(u'%5Cn', map(unicode, rows))%0A#    print converted_rows%0A%0A    new_soup = BeautifulSoup(converted_rows)%0A    new_rows = new_soup.findAll('td')    %0A    print type(new_rows)%0A    print new_rows%0A%0A    for data in new_rows:%0A        print type(data)%0A        cells = data.findAll('td')%0A#        if len(cells) == 31%0A        print type(cells)%0A#        name = cells%5B1%5D.find(text=True)%0A#        ht = cells%5B6%5D.find(text=True).replace(%22-%22, %22.%22)%0A#        ht = cells%5B3%5D.find(text=True)%0A        wt = cells%5B7%5D.find(text=True)%0A        print wt%0A%0A        f.writerow(%5Bname, ht, wt%5D)%0A%0A%0AgetStatsFromWeb(page1);%0A%0A%0A%0A

Add file