A comma-separated values (CSV) file is a simple text format used to store a list of records. A comma is used as a delimiter to separate the fields for each record. This format is commonly used to transfer data between a spreadsheet or
In this file format, the first line gives the products. The digit 0 indicates that a customer did not rate a product. In this case, the first customer rated A as 3, C as 5, D as 1, and E as 2. Product B was not rated. The third customer rated C as 5, D as 1, and E as 3. The third customer did not rate A or B.
Create a text file in this format with sample ratings. Then, write a program that reads in this text file and extracts each rating using the StringTokenizer class. Finally, the program should output the average rating for each product. Customers that did not rate a product should not be considered when computing the average rating for that product. Your program can assume there will always be exactly five products but it should work with an arbitrary number of customer ratings.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Modern Database Management
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- Sometimes data comes in as a structured format that you have to break down and turn into records so you can process them. CSV, or comma-separated values, is a common standard for doing this. Construct a program that reads in the following data file: Lee, Jason, 55900 Flores, Jim, 56500 Cruz, Aaron, 46000 Cruz, Chris, 34500 Swift, Geoffrey, 14200 Xiong, Fong, 65000 Zafra,Sabrina,51500 Process the records and display the results formatted as a table, evenly spaced, as shown in the example output. EXAMPLE OUTPUT Last Xiong Flores Lee Zafra Cruz Cruz Swift First Salary Fong $65,000 Jim $56,500 Jason $55,900 Sabrina $51,500 Aaron $46,000 Chris $34,500 Geoffrey $14,200 CONSTRAINTS 1. Write your own code to parse the data. Don't use a CSV parser 2. Use string formatting to properly space out the columns. Make each column one space longer than the longest value in the column. 3. Format the salary as currency with dollar signs and commas. 4. Sort the results by salary from highest to lowest.…arrow_forwardSometimes data comes in as a structured format that you have to break down and turn into records so you can process them. CSV, or comma-separated values, is a common standard for doing this. Construct a program that reads in the following data file: Lee, Jason, 55900 Flores, Jim, 56500 Cruz, Aaron, 46000 Cruz, Chris, 34500 Swift, Geoffrey, 14200 Xiong, Fong, 65000 Zafra,Sabrina,51500 Process the records and display the results formatted as a table, evenly spaced, as shown in the example output. EXAMPLE OUTPUT Last Xiong Flores Lee Zafra Cruz Cruz Swift First Salary Fong $65,000 Jim $56,500 Jason $55,900 $51,500 $46,000 $34,500 Geoffrey $14,200 Sabrina Aaron Chris CONSTRAINTS 1. Write your own code to parse the data. Don't use a CSV parser. (3 points) 2. Use string formatting to properly space out the columns. Make each column one space longer than the longest value in the column. (4 points) 3. Format the salary as currency with dollar signs and commas. (2 points) 4. Sort the results by…arrow_forwardWrite a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator ('|') in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space. Each row of the CSV file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Hints: Use the find() function to find the index of a comma in each row of…arrow_forward
- IN C++ Write a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator ('|') in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space. Each row of the CSV file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Hints: Use the find() function to find the index of a comma in each…arrow_forwardWrite a c program for a simple student record.Each record should contain the following information:● Surname – a string (surname of the student)● Sex – a character (M for male, F for female)● Year – an integer (year part of student number)● Snum – an integer (last five digits of the student number)● Department – a string (department the student is a part of)Your program should be able to allow the user to:● Add records● Display all records● Display all records filtered by sex/ year/ department● Display record(s) linked to a given snum (last five digits of a student number)Note: student number should be displayed following the format year - snumarrow_forwardSometimes data is not always in the format we need it to be in. In this hypothetical situation, you are writing a program to load phone numbers into a database from user entered survey data. The 10 digit phone number will be stored in the database as an integer (e.g. 1234567890), however the user may enter the phone number in any format (e.g. 123-456-7890). You will write a program that creates a new string from the user entered number consisting of only the digits so it should have the same structure as word_quiz.py in the Unit 5 lecture slides. Below are two examples of how your program should run with different inputs: Enter phone number: (530) 555-1212 Numbers: 5305551212 Enter phone number: 916-123-4567 Numbers: 9161234567 The last line of your program should be: print("Numbers:", phoneNum)arrow_forward
- Using Pandas library in python - Calculate student grades project Pandas is a data analysis library built in Python. Pandas can be used in a Python script, a Jupyter Notebook, or even as part of a web application. In this pandas project, you’re going to create a Python script that loads grade data of 5 to 10 students (a .csv file) and calculates their letter grades in the course. The CSV file contains 5 column students' names, score in-class participation (5% of final grade), score in assignments (20% of final grade), score in discussions (20% of final grade), score in the mid term (20% of final grade), score in final (25% of final grade). Create the .csv file as part of the project submission Program Output This will happen when the program runs Enter the CSV file Student 1 named Brian Tomas has a letter grade of B+ Student 2 named Tom Blank has a letter grade of C Student 3 named Margo True has a letter grade of A Student 4 named David Atkin has a letter grade of B+ Student 5 named…arrow_forwardComputer Science Write a python program that reads the data file https://archive.ics.uci.edu/ml/machine-learning-databases/eventdetection/CalIt2.data and finds the total count of outflow and the total count of inflow. The attributes in the file are as follows: 1. Flow ID: 7 is out flow, 9 is in flow 2. Date: MM/DD/YY 3. Time: HH:MM:SS 4. Count: Number of counts reported for the previous half hour Rows: Each half hour time slice is represented by 2 rows: one row for the out flow during that time period (ID=7) and one row for the in flow during that time period (ID=9) Hint: # Importing the dataset dataset = pd.read_csv('CalIt2.data') https://archive.ics.uci.edu/ml/machine-learning-databases/event-detection/CalIt2.data this link should work.arrow_forwardUsing C LANGUAGE build a system to manage patients’ data in a hospital. The hospital patient management system stores specific information in the form of health record to keep track of the patients’ data.Your program should read the information from a file called“patients.txt” that should be on the following format:Patient Name#Gender#Date of admission#Date of birth#Illness#Address (City)#Blood typeExample of data input:Abed Mukhles#M#2212019#01012000#EarInfection#Jenin#O+Nadia A. Ali#F#01102020#05101970#COVID-19#AlBireh#A1. You are required to implement a program to help creating the system byincluding the following operations of an AVL tree:• Read the file patients.txt and load the data (i.e., AVL Tree).• Insert a new patient from user with all its associated data.• Find a patient and give the user the option to update the informationof the patient if found.• List all patients in lexicographic order with their associatedinformation.• List all patients that have the same illness.•…arrow_forward
- Timesheet data is easy to represent in a file, where it can be used to generate a report and help the worker get paid! Given an example set of data where each row represents a day of the week and each entry on the row represents a block of time worked, like this: 0h1.5h 3.25h3.0h 6.0h 1.0h5.5h 2.25h 0.75h2.25h 3.0h 3.0h5.75h 2.25h0h A report could be produced by a program like this: ---------------------------------------0.00h | 0.00h5.25h | 1.50h 3.25h 0.50h10.00h | 3.00h 6.00h 1.00h8.50h | 5.50h 2.25h 0.75h8.25h | 2.25h 3.00h 3.00h8.00h | 5.75h 2.25h0.00h | 0.00h---------------------------------------Weekly Total: 40.00h Notice how in the output file all the numbers are nicely formatted as right-aligned. Hint: you will probably need to use splitting, string slicing, converting data types, and string formatting. For your assignment, create a program that uses a data file that you have created, parses the data in that file to create a calculation per row and a running total, then…arrow_forwardAn “inverted file” is a critical data structure for implementing applications like the index of a book, or a web search engine. Given a document D (which can be viewed as an unordered, numbered list of words), an inverted file is an ordered list of words L such that for each word W in L, we store the indices of the places in D where W appears. Write a C# program (from scratch please, written by yourself (ask instructor if you are stuck), not borrowed from any other sources) that reads in a list of words separated by spaces from a text file, then uses an efficient O(N) algorithm to create the inverted file index (hint: consider the topic of this chapter, consider using a Dictionary/hashtable to help you), and writes this index out to another file or prints it to the screen. Each line of the output file should start with the next word (the words should be listed in alphabetical order, and this sorting does not have to be part of the O(N) runtime complexity, e.g. you can use regular…arrow_forwardwrite in c++Write a program that would allow the user to interact with a part of the IMDB movie database. Each movie has a unique ID, name, release date, and user rating. You're given a file containing this information (see movies.txt in "Additional files" section). The first 4 rows of this file correspond to the first movie, then after an empty line 4 rows contain information about the second movie and so forth. Format of these fields: ID is an integer Name is a string that can contain spaces Release date is a string in yyyy/mm/dd format Rating is a fractional number The number of movies is not provided and does not need to be computed. But the file can't contain more than 100 movies. Then, it should offer the user a menu with the following options: Display movies sorted by id Display movies sorted by release date, then rating Lookup a release date given a name Lookup a movie by id Quit the Program The program should perform the selected operation and then re-display the menu. For…arrow_forward
- 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