Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package comp1110.exam; import java.io.IOException; /** * COMP1110 Exam, Question 2 * * IMPORTANT NOTE: This question depends on knowledge of Java NIO, which is not

package comp1110.exam; import java.io.IOException; /** * COMP1110 Exam, Question 2 * * IMPORTANT NOTE: This question depends on knowledge of Java NIO, which is not * taught in S2 classes. It can be solved without NIO, but is not intended for * students who are not familiar with NIO. */ public class Q2Awk { /** * Read the specified input file in comma-separated-value (CSV) format and * extract all values from the specified column, writing the values * (one per line) to the specified output file. * If sortOutput==true, the values in the specified column are written in * alphabetical order to the output file; otherwise, the values are written * in the same order as they occur in the input file. * If the specified column is missing a value for a given line, then that * line is ignored and is not included in the output. * If the specified column is not included in any line of the input file, * then the output file is empty. * 

* For example, if the input file "Q2kate.csv" contains the following lines: * Babooshka,1980,2 * Hounds of Love,1986, * Rubberband Girl,1993,39 * Running Up That Hill,1983,6 * Wuthering Heights,1978,1 * then the method call extractColumnCSV("Q2kate.csv", 2, "chart.csv", true) * would result in the following lines being written to the file "chart.csv": * 1 * 2 * 39 * 6 * * @param inputFilename the filename of the input file * @param column the number of the column to extract (0..n) * @param outputFilename the filename of the output file * @param sortOutput if true, the specified column is written to the output * file in alphabetical order * @throws java.nio.file.NoSuchFileException if the input file does not exist or * the output file cannot be created */ static void extractColumnCSV(String inputFilename, int column, String outputFilename, boolean sortOutput) throws IOException { // FIXME complete this method } }

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

3. Job rotation is used for all levels and types of employees.

Answered: 1 week ago