Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSVReaderTester.java : /** This program demonstrates and tests methods of the CSVReader class. */ public class CSVReaderTester { public static void main(String[] args) { CSVReader

image text in transcribed

CSVReaderTester.java :

/** This program demonstrates and tests methods of the CSVReader class. */ public class CSVReaderTester { public static void main(String[] args) { CSVReader reader1 = new CSVReader("att2007.csv"); CSVReader reader2 = new CSVReader("quotes.csv"); System.out.println("Number of rows: " + reader1.numberOfRows()); System.out.println("Expected: 214"); System.out.println("Number of fields in row 10: " + reader1.numberOfFields(10)); System.out.println("Expected: 7"); System.out.println("Row 10, Col 2: " + reader1.field(10, 2)); System.out.println("Expected: 24.95"); System.out.println("Number of rows: " + reader2.numberOfRows()); System.out.println("Expected: 2"); System.out.println("Number of fields in row 1: " + reader2.numberOfFields(1)); System.out.println("Expected: 4"); System.out.println("Row 1, Col 2: " + reader2.field(1, 2)); System.out.println("Expected: Hello, World"); System.out.println("Row 1, Col 3: " + reader2.field(1, 3)); System.out.println("Expected: He asked: \"Quo vadis?\""); System.out.println("Row 0, Col 3: " + reader2.field(0, 3)); System.out.println("Expected: \"..., that all men are created equal, ...\""); } }

quotes.csv :

image text in transcribed

att2007.csv :

image text in transcribed

The CSV (or comma-separated values) format is commonly used for tabular data. Each table row is a line, with columns separated by commas. Items may be enclosed in quotation marks, and they must be if they contain commas or quotation marks. Quotation marks inside quoted fields are doubled. Here is a line with four fields: 1729, San Francisco, "Hello, World", "He asked: ""Where are you going?""" Implement a class cvsReader that reads a CSV file, and provide the following methods int numberOf Rows() int numberOfFields (int row) String field(int row, int column) 11 Returns the field in a particular row and colum // Returns the number of lines in the CSV file // Returns the number of fields in a particular row Then, test your class with the tester class, provided, and with the two CSV files, provided

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

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Draw all the enol tautomers for each of the ketones in Problem 11.

Answered: 1 week ago