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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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. * <p> * 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 } }

 

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education