How to Read Data from CSV file using Java Code

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.พ. 2025
  • Hello
    In this tutorial, I will explain you How to read data from .CSV file using java code
    OpenCSV provides API’s to read and write data from/into a.CSV file.
    Using the readNext() method of the CSVReader class reads the next line of the .csv file and returns it in the form of a String array.
    maven dependency
    mvnrepository....
    mvnrepository....
    Selenium interview questions and answers for freshers and experienced: • Selenium interview que...
    Filesystem in java and selenium: • FileSystem_JAVA/Selenium
    Selenium beginners tutorials: • Selenium Beginner Tuto...
    Postman beginners tutorials: • Postman beginner tutorial
    Selenium : • Selenium
    Advance selenium: • Advance Automation
    Mobile testing: • Mobile Testing
    Please do subscribe for more tutorials on selenium automation @SH Study Tech
    Please share questions and queries in the comments section.
    Follow me on Facebook: SHStudyTech
    Follow me on Instagram : shstudytech
    Follow me on the blog: shstudytech.bl...
    Subscribe to youtube channel: / @sureshsdetautomation

ความคิดเห็น • 18

  • @keshavsaklani3174
    @keshavsaklani3174 2 ปีที่แล้ว +1

    Thanks for sharing this information 👍

  • @rohitsingh1136463
    @rohitsingh1136463 2 ปีที่แล้ว +1

    how to read each cell one by one so that can be used in sendkeys method

    • @SureshSDETAutomation
      @SureshSDETAutomation  2 ปีที่แล้ว +1

      Current code is not helping your requirement ?
      If no will add a session soon

    • @rohitsingh1136463
      @rohitsingh1136463 2 ปีที่แล้ว

      @@SureshSDETAutomation current code is reading all data together but unable to read and print each cell individually..

    • @SureshSDETAutomation
      @SureshSDETAutomation  2 ปีที่แล้ว +2

      Sure will add a session soon. Thanks for writing

  • @dibyajyotimohanty9252
    @dibyajyotimohanty9252 3 ปีที่แล้ว +1

    Hyy sir it's great explain
    Can you plz upload any video for nested json file into csv by using java code.

  • @pavang2827
    @pavang2827 2 ปีที่แล้ว +1

    Hi Can you help me with the CSV Comparison code with java using Two CSV Files

    • @SureshSDETAutomation
      @SureshSDETAutomation  2 ปีที่แล้ว

      You can use the same approach. If you are not able to do it will upload a session on this soon

  • @jyothirmaiarja2715
    @jyothirmaiarja2715 2 ปีที่แล้ว

    How can we get single row like employee details by using employee id.can u please answer me

    • @SureshSDETAutomation
      @SureshSDETAutomation  2 ปีที่แล้ว

      You can the same approach and add another condition or loop to filter like while or for

  • @RajuRaju-pg1hm
    @RajuRaju-pg1hm 9 หลายเดือนก่อน +1

    Can You please share the code

    • @SureshSDETAutomation
      @SureshSDETAutomation  9 หลายเดือนก่อน

      Thanks for writing
      Code is not available atm

  • @biswajitghosh3
    @biswajitghosh3 3 ปีที่แล้ว

    The string buffer is not used in this code .

    • @SureshSDETAutomation
      @SureshSDETAutomation  3 ปีที่แล้ว +1

      Yes
      As we have used CSV libraries and collection concepts.

  • @КонстантинБойцов-ы4д
    @КонстантинБойцов-ы4д 2 ปีที่แล้ว

    // 26 06 2022 18-14 в общем вроде как у человека работает джава ( ява) по идее нужно попробовать код набрал.
    package filesystem;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import com.opencsv.CSVReader;
    public class readCSVdata {
    public static void main(String[] args) throws FileNotFoundException {

    //installing the CSV reader class

    CSVReader reader = new CSVReader(new FileReader("CSVdatafiles\\testdata.csv"));

    // reading the data of the CSV filesystem

    StringBuffer buffer = new StringBuffer();
    String data[];

    while((data = reader.readNext()) !=null) {

    for(int i=0 ; i