Book Database
Book Database
This
dataset is on Amazon’s Top 50 bestselling books from 2009 to
2019. It keeps the record of 550 books in a .csv file.
Dataset entries
To begin working with the dataset, we need to read the data from
a CSV file named data.csv. This file contains information about
various books, structured in a tabular format. Each row
represents a book and includes details such as the title, author,
user rating, number of reviews, price, publication year, and
genre.
Attributes:
In the code above, we can have three java files used to read the
dataset. Lets explore the objective of each file as follows:
● The Book.java file defines the Book class, This class
represents a Book object with attributes for the title, author,
user rating, reviews, price, year, and genre. It includes
getters for each attribute and a printDetails method to print
the details of the book in a formatted manner.
● The DatasetReader.java file is responsible for reading a CSV
file and creating a list of Book objects. It handles the parsing
of each line in the CSV, ensuring that each book has the
required data fields, and skips malformed lines.
● The driver.java file contains the main method, which serves
as the entry point of the program. It uses DatasetReader to
read the dataset from the CSV file, and then iterates over
the list of Book objects to print their details using the
printDetails method of the Book class.
Tasks
1. Total number of books by an author
○ It takes the name of an author and dataset as input
and returns the total number of books written by the
author
2. All the authors in the dataset
○ Print name of all authors in the dataset
3. Names of all the books by an author
○ It takes the author as an input and returns all the
books written by the author. Just for reference, Author
is the second column, and Name (name of the book) is
the first column in the dataset.
4. Classify with a user rating
○ It takes the rating as an input and returns all books
with the user rating equal to rating.
5. Price of all the books by an author
○ It takes the name of the author as an input and returns
the names and prices of all the books written by the
author.