Can you help me fix my code, the assignment is in the photos
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; import javax.swing.filechooser.*; import javafx.application.Application; import javafx.event.*; import javafx.scene.*; import javafx.scene.text.*; import javafx.scene.control.*; import javafx.scene.control.Alert.*; import javafx.scene.layout.*; import javafx.stage.*; import javafx.geometry.*; import java.io.*;
public class CsvIo extends Application implements EventHandler { private Stage stage; private Scene scene; private TextField tfFileName = new TextField(); private TextField tfRecordsIn = new TextField(); private TextField tfRecordsOut = new TextField(); private TextField[] tfAll = {tfFileName, tfRecordsIn, tfRecordsOut}; private String[] tfLabels = {"File: ", "Records In: ", "Records Out: "}; private int[] tfWidths = {10, 3, 3}; private Button jbOpen = new Button("Open"); private String fileName = ""; private File fileObj = null; private FileInputStream fis = null; private DataInputStream dis = null; private FileOutputStream fos = null; private DataOutputStream dos = null; public static void main(String[] args) { launch(args); } public void CsvIo(Stage _stage){ // Set up window stage = _stage; stage.setTitle("Baseball"); VBox root = new VBox(8); GridPane gpTop = new GridPane(); for(int i = 0; i info = new ArrayList(Arrays.asList(split)); for(int i = 0; i
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". 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