How to Read CSV File using Open CSV In Java

Suraj Mishra
Javarevisited
Published in
4 min readMar 25, 2022

--

Originally published at https://asyncq.com

Introduction

CSV files are one of the common way to store , exchange structured data between servers along with another popular structured data format. There are many libraries to read CSV files and one of the popular library is OpenCSV. In this article, we will use OpenCSV library to read CSV file using Java.

Input File

I am using Netflix daily top 10 datasets from kaggle as my input file.

Open CSV is one of the most popular CSV parsers. It provides both basics and advanced functionalities that are more than sufficient to read any CSV file. For example, if we want to skip Header from the CSV file, we can easily do so with the skip_line method. If we need to validate row before processing it , we can write using the RowValidator interface and filter out all the rows that don’t follow validation.

Reading CSV File

Reading Using CSVReader

A simplest client that can be built is using CSVReader class. We need to pass FileReader Object

--

--