Write a Java program to load, parse, and filter the data contained in a CSV file
ID: 3797758 • Letter: W
Question
Write a Java program to load, parse, and filter the data contained in a CSV file for that data set.
Your Java code should consist of a main method (also called the program driver).
The driver will call several static methods that will open the CSV data file, parse a single column from the data contained in the file, and print that column to a new file.
Implement a static method copyColumn(String out, int n) that will read data from column n in the CSV data file, and write it out to a new file whose name is contained in the variable out. Implement a static method filterColumn(String out, int n, ________) that will read data from column n in the CSV data file, filter the data based on a criteria passed as the third argument and write the data to a new file whose name is contained in the variable out.
The third argument will depend on the type of data you are filtering:
• If your columns contain numerical data, pass a double parameter called "max" and have your method only copy values from the column that are less than the maximum.
• If your columns contain labels or String data, pass a String parameter called "matchThis" and have your method only copy values from the column that contain the String matchThis.
Explanation / Answer
I am assuming that csv file is of format 1,A,B,C i.e, without quotation marks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.