I am trying to import a .csv file and save data in objects for later manipulation in Python. I am very new to coding so please do let me know my fundamental errors.
import csv
import os
import time
import numpy
import itertools
def __init__(p):
p.playerFile = csv.reader(open("dk.csv", "rb"))
p.playerList = []
p.playerName = ''
p.playerPosition = ''
p.PlayerGameInfo = ''
p.playerPrice = 0
def loadCSV(p):
for row in p.playerFile:
playerObject = Player()
playerObject.setPlayerName(row[1]) # Store player name
playerObject.setPlayerPosition(row[0]) # Store player position
playerObject.setPlayerGameInfo(row[3]) # Store player team
playerObject.setPlayerPrice(row[2]) # Store player price
def getPlayerName(p):
return p.PlayerName
def getPosition(p):
return p.playerPosition
def getGameInfo(p):
return p.PlayerGameInfo
def getPrice(p):
return p.PlayerPrice
def setPlayerName(p, player):
p.playerName = name
def setPlayerPosition(p, playerPosition):
p.playerPosition = position
def setPlayerGameInfo(p, PlayerGameInfo):
p.PlayerGameInfo = team
def setPlayerPrice(p, playerPrice):
p.playerPrice = price
with open('~/dk.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
print (row)