
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
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
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)](https://content.bartleby.com/qna-images/question/10db7dd5-51b9-4abe-a748-6884ff91846b/372d3a9c-60e4-4290-b41c-31a5fed019b4/ouxqo8j_thumbnail.jpeg)
Transcribed Image 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)
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](https://content.bartleby.com/qna-images/question/10db7dd5-51b9-4abe-a748-6884ff91846b/372d3a9c-60e4-4290-b41c-31a5fed019b4/m7dyr6_thumbnail.jpeg)
Transcribed Image 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
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- What is the default permission assigned when you create a file with umask a. 666 b. 777 c. 022 d. 644arrow_forwardWhich one of the following statements about unique value filtering is true? a. Selected values are sorted b. Selected values are not displayed c. Selected values are deleted from the file d. Selected values are displayedarrow_forwardWhat are CSV (comma-separated values) text files? What is an easy command for splitting each CSV record into different fields?arrow_forward
- DO NOT COPY FROM OTHER WEBSITES Upvote guarenteed for a correct and detailed answer. Thank you!!!arrow_forwardDescription i What is timestamp? Note that we have only timestamps, which ALWAYS contain yyyy-mm-dd as a date, hh:mm:ss as a time, and +/-zzzz as a timezone. time 2017-10-14 00:11:20 +0000 date time zone 12345 + timeconverter.py 1 def convert_time(timestamp): #NOTE: COMPLETE THE CODE FROM HERE! 6 #DO NOT MODIFY THE CONTENT HERE: 7 def print_result(hour, minute): 8 9 print("The time is {}:{}".format(hour, minute)) 10 #DO NOT MODIFY THE CONTENT HERE: 11 timestamp_list = ['2017-10-14 00:11:20 +0000', 12 '2022-03-24 07:22:16 -0400' Topic: Timestamp Converter Write a program timeconverter.py that has two functions: 1) The function convert_time : for extracting the hour and minute from a timestamp and 2) The function print_result: for printing the results. Note that the two functions should be called under the loop. 1) The function convert_time should: 1. take the timestamp from the function call, 2. separate time from date and time zone, 3. split it into hour, minute and seconds, 4. extract…arrow_forwardHow do create txt file that has a lists of students first and last names their grades from 8 different course, and the teacher comments from those 8 different courses. Would it be like the one show below.arrow_forward
- Assuming the file "File.txt" exists, where must it be located for this code snippet to work without error? ifstream in_file; in_file.open ("File.txt"); In system RAM On the hard drive or flash drive In the same folder (directory) as the source code (.cpp) All of thesearrow_forwardWhat controls are available to prevent the file from being destroyed or contaminated, or to restore a damaged file?arrow_forwardThe file name is file1.txt How would you inclue this?arrow_forward
- Print a single formatted record SPOOL your output to c:\Folder\project4spool.txt Set SERVEROUTPUT ON to use the DBMS_OUTPUT package Declare variables for the entire record using %ROWTYPE Use SELECT INTO to load a record from DDI.LEDGER_VIEWwhere REGID = 8 Use DBMS__OUTPUT.OUTPUT_LINE to print the values for each fieldconcatenate FIRSTNAME and LASTNAME into a single name and use"TO_CHAR to format dates as 'MM/DD/YYYY' and currency as '999,999.00' Compile and run the procedure Close spoolarrow_forwardPython Find the P10 value of a dataset from a .csv file using your own code and without the use of the percentile function in Numpy or Pandas.arrow_forward3. Which command can you use to look for the file names status.report? Which command can you use to look at the end of the file?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education