I am currently trying to run a Python script to pull some data from a Yahoo Fantasy Football Website. I have been able to successfully scrape data, but am running into an issue with the CSV output. All of the data is being put into one column instead of multiple different columns. Below is my code I am using:

import re, time, csv
import requests
from bs4 import BeautifulSoup

League_ID = 1459285
Week_Number = 1
Start_Week = 1
End_Week = 13
Team_Name = "Test"
Outfile = 'Team_Stats.csv'
Fields = ['Player Name', 'Player Points', 'Player Team', 'Week']

with open('Team_Stats.csv','w') as Team_Stats:
        f = csv.writer(Team_Stats, Fields, delimiter=',', lineterminator='n')

    for Week_Number in range(Start_Week, End_Week + 1):
            url = requests.get("https://football.fantasysports.yahoo.com/f1/" + str(League_ID) + "https://stackoverflow.com/2/team?&week=" + str(Week_Number))
            soup = BeautifulSoup(url.text, "html.parser")
            #print("Player Stats for " + Team_Name + " for Week " + str(Week_Number))

            player_points=soup.find_all('a',{'class':'pps Fw-b has-stat-note '})

            for player_name in player_name:
                    player_name = player_name.contents[0]

            for player_points in player_points:
                    Week_Number += 1

    print("Process Complete")

I also want to leave some room in the code to add more ‘For loops’ since I have other pieces of data I am looking to collect.

If anyone can suggest a better way to structure my code, please feel free to help!!

This is a sample output of what I get in my csv file

screen shot