title: Python - Combining excels after scraping
body: <p>I followed another persons code to scrape basketball player data for a player for a year, I've automated it so that I can scrape for X player for Y years, but it outputs an excel per year. Is there anyway to scrape it all and have it all in the one excel/csv at the end?</p>
  <pre><code>from urllib.request import urlopen
  from bs4 import BeautifulSoup
  import pandas as pd
  from time import sleep
  from random import randint
  from datetime import date
  import numpy as np
  
  poop = []
  # NBA season and player we will be analyzing. Basketball-reference's html code is weird so inputs are in place to extract
  year = input(&quot;Year End Season: &quot;)
  initial = input(&quot;Initial of Last Name: &quot;)
  last_name = input(&quot;First 5 letters of last name: &quot;)
  first_name = input(&quot;First 2 letters of first name (and 01 at the end unless multiple players with that name): &quot;)
  Number_pages = int(input(&quot;How many years to scrape? &quot;))
  
  years = range(Number_pages)
  
  for adds in years:
      # URL page we will scraping with inputs from above
      url = &quot;https://www.basketball-reference.com/players/&quot; + str(initial) + &quot;/&quot; + str(last_name) + str(first_name) + &quot;/gamelog/&quot; + str(int(year) + int(adds))
  
      # this is the HTML from the given URL
      html = urlopen(url)
      soup = BeautifulSoup(html, features=&quot;lxml&quot;)
  
      sleep(randint(2,10))
  
      print(soup.div.h1.text.strip())
  
      # use findALL() to get the column headers
      container = soup.find('div', class_='table_outer_container')
      container.findAll('tr', limit=2)
      # use getText()to extract the text we need into a list
      headers = [th.getText() for th in container.findAll('tr', limit=2)[0].findAll('th')]
  
      # exclude the first column as we will not need the ranking order from Basketball Reference for the analysis
      headers = headers[1:]
      headers
  
      # avoid the first header row
      rows = container.findAll('tr')[1:]
      player_stats = [[td.getText() for td in rows[i].findAll('td')]
                  for i in range(len(rows))]
  
      stats = pd.DataFrame(player_stats, columns = headers)
      stats.head(10)
      poop.append(stats)
  
      stats.to_csv(soup.div.h1.text.strip() + '.csv')
  </code></pre>