From 03aaa6978fbd73c13b63f0c525f01189c67d0f1f Mon Sep 17 00:00:00 2001 From: Rasmus Luha Date: Wed, 16 Mar 2022 18:50:37 +0200 Subject: API requests done --- AllAboutData/getData.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'AllAboutData/getData.py') diff --git a/AllAboutData/getData.py b/AllAboutData/getData.py index 7c64b30..4cea9af 100644 --- a/AllAboutData/getData.py +++ b/AllAboutData/getData.py @@ -84,10 +84,12 @@ def getPlayerData(url, headers): "height_feet" : player["height_feet"], "height_inches" : player["height_inches"]}) - #add player to dataframe + # Add player to dataframe playerDf.loc[len(playerDf)] = playerSeries - #add dataframe to File - playerDf.to_csv(playersDir+teamName+".csv", mode='a', index=False, header=False) + + # Add dataframe to File + hdr = False if os.path.isfile(playersDir+teamName+".csv") else True + playerDf.to_csv(playersDir+teamName+".csv", mode='a', index=False, header=hdr) print("Page "+str(el)+" read.") print("All done, check \"Data\" Dir.") @@ -95,7 +97,6 @@ def getPlayerData(url, headers): -# Requesting and storing data if __name__ == "__main__": getTeamsData(url, headers) getPlayerData(url, headers) -- cgit v1.2.3