About CSV File
CSV file abbreviation is comma separated value which means that CSV file we can open in the notepad with comma separated values by deault. The CSV file name contains extension is .csv and it is very light weight format and flexible format we can open it in the different text editor tool also instead of opening only in excel software, which are notepad, notepad++, editplus, ultraedit, any IDE(netbeans, eclipse, RAD, IntelliJ etc..) etc… If we will compare to excel file which is having number of rows limitation per sheet but in the CSV file there is no limit.
Excel file should be opened in Excel software only but CSV file can be opened in the different tools as mentioned above. Reading & writing of excel file is complexity but reading and writing of CSV file very straight forward methods exist in opencsv jar.
Many tools / softwares support csv file format export option with different types of delimiters. for example SQLDeveloper, MySQL UI, Toad etc… export data into csv format with different types of delimiters which are comma(,), slash(#), colon(;), pipe(|), double pipe(||), dollar($) etc… you can see these delimiters in the keyboard on function keys.
In this section we are going to explain how to read CSV file and write CSV file in different ways by using openCSV jar file in java. You can see the examples in the next chapter.
Sample CSV Data
FIRSTNAME,LASTNAME,AGE Narayana,Ragi,30 Kumar,Chitra,50 Swamy,Bathala,40
How to create CSV file by using notepad
- Open notepad
- Paste the below data into notepad
- Save it as like “OpenCsvRead.csv” in the double quote as file name.
You can see sample programs in the next chapter how to read and write csv file in java by using opencsv jar file.