How to Read Data from CSV file in Java | Reading a CSV with CSVReader Example in Java

Published: 10 March 2023
on channel: Azhar Techno Coder
651
33

How to Read Data from CSV file in Java | Reading a CSV with CSVReader Example in Java

PreRequisite:
Add a dependency of opencsv in pom.xml

dependency
groupId com.opencsv /groupId
artifactId opencsv /artifactId
version 5.7.0 /version
/dependency

Chapters:
0:00 - Introduction to the video
0:36 - Reading a CSV with CSVReader Example in Java
3:55 - Execution of the program

Code:
package com.general.interviewQuestions;
import java.io.FileReader;
import com.opencsv.CSVReader;

public class readCSVFileCSVReader {
public static void main(String[] args) {
CSVReader reader = null;
try {
reader = new CSVReader(new FileReader("C:/Users/AZHAR PC/eclipse-workspace/GeneralInterviewQuestions/DataFiles/ScannerCsv.csv"));
String[] next;
while((next = reader.readNext())!= null) {
for(String csvFileValues:next) {
System.out.print(csvFileValues+" ");
}
System.out.println("\n");
}
}catch(Exception e) {
e.printStackTrace();
}

}
}


Next Steps :

---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists

► 1. Javascript -    • Javascript Factory  
► 2. Puppetter -    • Puppeteer  
► 3. Cypress -    • Cypress  
► 4. Tech works -    • Video  
► 5. Vbscript Basics To Advanced -    • VBScript Part 1 -  Features Advantage...  
► 6. Jmeter -    • Jmeter Tutorials  
► 7. Excel -    • Videos On Excel  
► 8. Appium -    • Appium  
► 9. Shares -    • Shares  
► 10. Javascript Interview Questions -   • Javascript Interview Questions  
► 11. C# Tutorials -    • C# Factory  
► 12. HTML & CSS -    • HTML & CSS  
► 13. Browser Console -    • Browser Console  
► 14. JSON -    • Videos on Json  
► 15. Specflow -    • Specflow Tutorials  
► 16. MongoDB -    • MongoDB Tutorials  
► 17. Postman -    • Postman  
► 18. Python -    • Python  
► 19. Typescript -    • Typescript & Node Imp Questions  
► 20. Node -    • Node  
► 21. Java Selenium Interview Questions:    • Java and Selenium Imp  
► 22. Real Time Interview Q & A:    • Real Time Interview Questions  
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------

#readcsv
#java
#csvreader


On this page of the site you can watch the video online How to Read Data from CSV file in Java | Reading a CSV with CSVReader Example in Java with a duration of hours minute second in good quality, which was uploaded by the user Azhar Techno Coder 10 March 2023, share the link with friends and acquaintances, this video has already been watched 651 times on youtube and it was liked by 33 viewers. Enjoy your viewing!