File Edit Format Run Options Window Help from datetime import datetime from FileIO import read csv, write csv # to print and process dates # to read and write files # tuple of valid positi VALID...

Please help - I cannot get my fileIO.py to read the CSV file into my main code. Please let me know if I’m doing soemthing incorrect, I have all files in the same file as well.
File Edit Format Run Options Window Help<br>from datetime import datetime<br>from FileIO import read csv, write csv<br># to print and process dates<br># to read and write files<br># tuple of valid positi<br>VALID POSITIONS =<br>('C', '1B', '2B', 'SS', 'LF', 'CF', 'RF', 'P')<br>main<br>':<br># main driver function<br>if<br>name<br>data = read csv()<br>now = datetime.now()<br># fetch the csv file data using read csv function<br># store the current date, month and year<br># printing to the display<br>print (

Extracted text: File Edit Format Run Options Window Help from datetime import datetime from FileIO import read csv, write csv # to print and process dates # to read and write files # tuple of valid positi VALID POSITIONS = ('C', '1B', '2B', 'SS', 'LF', 'CF', 'RF', 'P') main ': # main driver function if name data = read csv() now = datetime.now() # fetch the csv file data using read csv function # store the current date, month and year # printing to the display print ("=" *60) string = "Basketball Team Manager"| print (string.rjust (len (string) + 20, " ")) # print the current date print ("CURRENT DATE: ", end="") print (now.strftime("%Y-%m-%d")) # get the game data print ("GAME DATE: " input_ = input () if input : date = list (map(int, input .split("-"))) date of match = datetime(date[0], date[1]], date[2]). print ("DAYS UNTIL GAME: ", end="") print ((date of match - now).days) end="") # if the game data value was inputted # convert input to list of ints. eg: 2020 # print the difference in data # print the menu print ("\NMENU OPTIONS\n" + Display lineup" + "\n" "2 "1 Add player" + "\n" + "3 Remove player" + "\n" + Move player" + "\n" + Edit player position" + "\n" + "6 "4 "5 Edit player stats" + "\n" + "7 - Exit program\n") print (", ".join (VALID_POSITIONS)) print ("=" * 60) while True: # infinite loop until user enters the value 7 option = input ("\nMenu option: ") if option == "1": # print the elements with padding print (" " * 3 + f"{'Player'.ljust(31)}{'POS'.ljust(6)}{'AB'.ljust (6)}{'H'.ljust(6; print ("=" *60) for idx, data in enumerate (data, 1): # to print the player lineup # get the data number = str(idx) name = data["name"] position = data["position"] at bats = data["at bats"] hits = data["hits"] avg = int (hits) / int (at_bats) # calculate the average # using rjust to add the necessary space paddings number number.ljust (3)
FilelO.py- C:/Users/lyart/OneDrive/Desktop/project2_AppDevelopment/FilelO.py (3.9.1)<br>File Edit Format Run Options Window Help<br>import csv<br>def read csv():<br>Function to read data from the players.csv file<br>data = []<br># to store the data from the csv file<br>with open ('players.csv') as csv 'file:<br># using context manager to open and close t<br>CVs reader = csv.reader(csy file)<br>for row in cvs reader:<br>{

Extracted text: FilelO.py- C:/Users/lyart/OneDrive/Desktop/project2_AppDevelopment/FilelO.py (3.9.1) File Edit Format Run Options Window Help import csv def read csv(): Function to read data from the players.csv file data = [] # to store the data from the csv file with open ('players.csv') as csv 'file: # using context manager to open and close t CVs reader = csv.reader(csy file) for row in cvs reader: {"name": row[0], "position": row[1], "at bats": row[2], "hits": row[3] } dictionary # storing the data into a dictionary data.append (dictionary) # creating a list of dictionary objects return data # return data to the main program def write csv(data): Function to write data back to the players.csv file with open('players.csv', 'w') as csv file: writer = csv.writer(csv fi'e) # using context manager to open and cl for row in data: writer.writerow(row.values(() ) # writing data to the file
Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here