Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The assignment is in the photos. I wasn't able to upload BaseballNames1 and BaseballNames2. Problem Statement: An extract of some names and personal information has

The assignment is in the photos. I wasn't able to upload BaseballNames1 and BaseballNames2.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Problem Statement: An extract of some names and personal information has been made from a baseball database. This assignment is to read the data from a comma separated value text file (CSV), write the data into a binary file, then read it back in writing the data to the screen showing that the data in the binary file is intact and correct. You must implement the following GUI: pan R. Ruch Out - - Open file Name Records Out tRecordsin Dulu Pont MONOSPACED, 12 point When the user clicks the Open button, display a FileChooser that shows CSV files in the current directory and let the user choose one. You will create a similarly named .dat file. Example: Given filename BaseballNames2.csv, the output file is named BaseballNames2.dat. Input Datafile layout: Two CSV datafiles have been provided for testing, BaseballNames1.csv and BaseballNames2.csv. Each contains a header line as the first line of the file. A blank line may or may not follow. Your program must account for a blank or non- blank line (record) regardless of what the sample file shows. The program must also account for leading and trailing spaces or tabs in the data (see the String method trim for help with this), along with various errors. Field name Name First Name Last Birth Day Birth Month Birth Year Weight Height Data type Text Text Whole number Whole number 4-digit year Whole number Number with decimal part BaseballNames1.csv contain no errors, and your program must be able to process this one cleanly before you move to the next datafile. BaseballNames2.csv may have a value for each expected field and may not. Since this was a database extract, some missing (null) fields show up in the data. Some records may have one or more missing fields. Write errors to the taData text area and only valid records to the dat file. When an error is encountered in a line read in from the CSV, write the line and first error found to taData. Then continue to process the rest of the file. Your program will then read your created * dat data file and print it to taData. Reporting multiple errors per record is a bonus, described below. Correctly writing the above with Javadocs, can gain you full credit for this homework. My Solution Together with the two csv files, the Downloads for HW3 include a jar file for my solution called BaseballA.jar. You can run this to see how your program should run. The bonuses are not provided in this solution. The program BaseballB.jar is my solution with the bonus levels (both of them) in place. Bonus levels: Bonus level 1 is to reporting all errors in any one record. Level 1 allows printing the original record for each error reported. See sample output for Bonus Level 1. Bonus level 2 is to report all errors, but only display the original record once. Also, handle records with not enough fields (7) without a fatal error. See sample output for Bonus Level 2. Level 2 adds to the points from level 1. Output datafile layout: The binary output (dat) file must have the fields in the same order as the input. No headings are written in the output file, only the data. The appropriate binary I/O data types must be used, text must be written as text, numbers must be written as the appropriate numeric data type. You must use the appropriate methods of DatalnputStream and DataOutputStream for all I/O to the ".dat" file. Output report: At the end of reading the csv file, and writing the dat file, display how many records were read from the csv file in tfRecordsin and how many records were written to the dat file in tfRecordsOut. Remember to count the heading and blank lines as records read in, but not written out. Similarly, records with errors are records read in but not written out Use formatted printing, so the output report looks impressive. Spacing does not have to be exactly as shown, but it should be close. Hints: Dates are provided in the western format of "month, day, year". We suggest getting BaseballNames1.csv to work first. Save a backup copy of the code, then start on BaseballNames2.csv. Make sure you hand in something before the due date. Any bonus points won't make up for the late deductions. Dropbox: Send to the dropbox your best version of the file processing. Do NOT submit more than one version, as the wrong one may be graded, lowering your grade. This homework is due into the dropbox by the date/time shown on the dropbox. Bonus levels: Bonus level 1 is to reporting all errors in any one record. Level 1 allows printing the original record for each error reported. See sample output for Bonus Level 1. Bonus level 2 is to report all errors, but only display the original record once. Also, handle records with not enough fields (7) without a fatal error. See sample output for Bonus Level 2. Level 2 adds to the points from level 1. Output datafile layout: The binary output (dat) file must have the fields in the same order as the input. No headings are written in the output file, only the data. The appropriate binary I/O data types must be used, text must be written as text, numbers must be written as the appropriate numeric data type. You must use the appropriate methods of DataInputStream and DataOutputStream for all I/O to the ".dat" file. Output report: At the end of reading the csv file, and writing the dat file, display how many records were read from the csv file in tfRecordsin and how many records were written to the dat file in tf RecordsOut. Remember to count the heading and blank lines as records read in, but not written out. Similarly, records with errors are records read in but not written out Use formatted printing, so the output report looks impressive. Spacing does not have to be exactly as shown, but it should be close. Hints: Dates are provided in the western format of "month, day, year". Sample outputs: BaseballNames1.csv no errors. Use this for initial testing only. Baseball - P. Lutz File: BaseballNames1.csv Open Records in: 22 Records Out: 20 First Last name Birthdate Weight Height Starlin Castro Madison Bumgarner Jason Heyward Ruben Tejada Jenrry Mejia Mike Stanton Dayan Viciedo Chris Sale Freddie Freeman Clayton Kershaw Travis Snider Elvis Andrus Trevor Cahill 3/24/1990 8/1/1989 8/9/1989 10/27/1989 10/11/1989 11/8/1989 3/10/1989 3/30/1989 9/12/1989 3/19/1988 2/2/1988 8/26/1988 3/1/1988 190 215 240 160 160 235 240 170 225 225 235 200 220 72.8 76.0 77.3 71.2 72.5 77.9 71.1 77.2 77.7 75.4 72.0 72.0 76.0 There are more lines than are shown here, as indicated by the vertical scrollbar. Single error reported per record (BaseballNames2.csv) Baseball - P. Lutz File: BaseballNames2.csv Open Records In: 16 Records Out 4 Offending item is: Height Error found in: Gerardo Parra , 6, 5, 1987 offending item is: Weight Error found in: Mat Latos null, nui offending item is: Birth day First & Last name Birthdate Weight Height = Ryan Kalish Cameron Maybin Sean O'Sullivan Josh Reddick 3/28/1988 4/4/1987 9/1/1987 2/19/1987 205 210 230 180 73.0 75.0 74.0 74.0 Multiple errors reported per record (BaseballNames3.csv) and record with insufficient fields Baseball - P. Lutz File: BaseballNames3.csv Open Records In: 20 Records Out: 2 Not enough fields in the record. Error found in: Gerardo null, nu: offending data: Birth day, Birth month, Birth yea Error found in O'Sullivan Offending data: Birth day, Birth month, Birth yea Error found in: orfending data: Birth day, Birth month, Birth yea Error found in: Josh eddick null, offending data: Birth day, Bilth month, Birth yea Parra Sean + Mat Latos 9, 12 First Last name Birthdate Weight Height = Ryan Kalish Conor Gillaspie 3/28/1988 7/18/1987 205 200 73.2 73.3 - 1 Problem Statement: An extract of some names and personal information has been made from a baseball database. This assignment is to read the data from a comma separated value text file (CSV), write the data into a binary file, then read it back in writing the data to the screen showing that the data in the binary file is intact and correct. You must implement the following GUI: pan R. Ruch Out - - Open file Name Records Out tRecordsin Dulu Pont MONOSPACED, 12 point When the user clicks the Open button, display a FileChooser that shows CSV files in the current directory and let the user choose one. You will create a similarly named .dat file. Example: Given filename BaseballNames2.csv, the output file is named BaseballNames2.dat. Input Datafile layout: Two CSV datafiles have been provided for testing, BaseballNames1.csv and BaseballNames2.csv. Each contains a header line as the first line of the file. A blank line may or may not follow. Your program must account for a blank or non- blank line (record) regardless of what the sample file shows. The program must also account for leading and trailing spaces or tabs in the data (see the String method trim for help with this), along with various errors. Field name Name First Name Last Birth Day Birth Month Birth Year Weight Height Data type Text Text Whole number Whole number 4-digit year Whole number Number with decimal part BaseballNames1.csv contain no errors, and your program must be able to process this one cleanly before you move to the next datafile. BaseballNames2.csv may have a value for each expected field and may not. Since this was a database extract, some missing (null) fields show up in the data. Some records may have one or more missing fields. Write errors to the taData text area and only valid records to the dat file. When an error is encountered in a line read in from the CSV, write the line and first error found to taData. Then continue to process the rest of the file. Your program will then read your created * dat data file and print it to taData. Reporting multiple errors per record is a bonus, described below. Correctly writing the above with Javadocs, can gain you full credit for this homework. My Solution Together with the two csv files, the Downloads for HW3 include a jar file for my solution called BaseballA.jar. You can run this to see how your program should run. The bonuses are not provided in this solution. The program BaseballB.jar is my solution with the bonus levels (both of them) in place. Bonus levels: Bonus level 1 is to reporting all errors in any one record. Level 1 allows printing the original record for each error reported. See sample output for Bonus Level 1. Bonus level 2 is to report all errors, but only display the original record once. Also, handle records with not enough fields (7) without a fatal error. See sample output for Bonus Level 2. Level 2 adds to the points from level 1. Output datafile layout: The binary output (dat) file must have the fields in the same order as the input. No headings are written in the output file, only the data. The appropriate binary I/O data types must be used, text must be written as text, numbers must be written as the appropriate numeric data type. You must use the appropriate methods of DatalnputStream and DataOutputStream for all I/O to the ".dat" file. Output report: At the end of reading the csv file, and writing the dat file, display how many records were read from the csv file in tfRecordsin and how many records were written to the dat file in tfRecordsOut. Remember to count the heading and blank lines as records read in, but not written out. Similarly, records with errors are records read in but not written out Use formatted printing, so the output report looks impressive. Spacing does not have to be exactly as shown, but it should be close. Hints: Dates are provided in the western format of "month, day, year". We suggest getting BaseballNames1.csv to work first. Save a backup copy of the code, then start on BaseballNames2.csv. Make sure you hand in something before the due date. Any bonus points won't make up for the late deductions. Dropbox: Send to the dropbox your best version of the file processing. Do NOT submit more than one version, as the wrong one may be graded, lowering your grade. This homework is due into the dropbox by the date/time shown on the dropbox. Bonus levels: Bonus level 1 is to reporting all errors in any one record. Level 1 allows printing the original record for each error reported. See sample output for Bonus Level 1. Bonus level 2 is to report all errors, but only display the original record once. Also, handle records with not enough fields (7) without a fatal error. See sample output for Bonus Level 2. Level 2 adds to the points from level 1. Output datafile layout: The binary output (dat) file must have the fields in the same order as the input. No headings are written in the output file, only the data. The appropriate binary I/O data types must be used, text must be written as text, numbers must be written as the appropriate numeric data type. You must use the appropriate methods of DataInputStream and DataOutputStream for all I/O to the ".dat" file. Output report: At the end of reading the csv file, and writing the dat file, display how many records were read from the csv file in tfRecordsin and how many records were written to the dat file in tf RecordsOut. Remember to count the heading and blank lines as records read in, but not written out. Similarly, records with errors are records read in but not written out Use formatted printing, so the output report looks impressive. Spacing does not have to be exactly as shown, but it should be close. Hints: Dates are provided in the western format of "month, day, year". Sample outputs: BaseballNames1.csv no errors. Use this for initial testing only. Baseball - P. Lutz File: BaseballNames1.csv Open Records in: 22 Records Out: 20 First Last name Birthdate Weight Height Starlin Castro Madison Bumgarner Jason Heyward Ruben Tejada Jenrry Mejia Mike Stanton Dayan Viciedo Chris Sale Freddie Freeman Clayton Kershaw Travis Snider Elvis Andrus Trevor Cahill 3/24/1990 8/1/1989 8/9/1989 10/27/1989 10/11/1989 11/8/1989 3/10/1989 3/30/1989 9/12/1989 3/19/1988 2/2/1988 8/26/1988 3/1/1988 190 215 240 160 160 235 240 170 225 225 235 200 220 72.8 76.0 77.3 71.2 72.5 77.9 71.1 77.2 77.7 75.4 72.0 72.0 76.0 There are more lines than are shown here, as indicated by the vertical scrollbar. Single error reported per record (BaseballNames2.csv) Baseball - P. Lutz File: BaseballNames2.csv Open Records In: 16 Records Out 4 Offending item is: Height Error found in: Gerardo Parra , 6, 5, 1987 offending item is: Weight Error found in: Mat Latos null, nui offending item is: Birth day First & Last name Birthdate Weight Height = Ryan Kalish Cameron Maybin Sean O'Sullivan Josh Reddick 3/28/1988 4/4/1987 9/1/1987 2/19/1987 205 210 230 180 73.0 75.0 74.0 74.0 Multiple errors reported per record (BaseballNames3.csv) and record with insufficient fields Baseball - P. Lutz File: BaseballNames3.csv Open Records In: 20 Records Out: 2 Not enough fields in the record. Error found in: Gerardo null, nu: offending data: Birth day, Birth month, Birth yea Error found in O'Sullivan Offending data: Birth day, Birth month, Birth yea Error found in: orfending data: Birth day, Birth month, Birth yea Error found in: Josh eddick null, offending data: Birth day, Bilth month, Birth yea Parra Sean + Mat Latos 9, 12 First Last name Birthdate Weight Height = Ryan Kalish Conor Gillaspie 3/28/1988 7/18/1987 205 200 73.2 73.3 - 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

9. Describe the characteristics of power.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago