CSV Read in java

Friday, December 14, 2012

CSV, comma separated values, files are commonly used to transport large amounts of tabular data between either companies or applications that are not directly connected. The files are easily editable using common spreadsheet applications like Microsoft Excel.

Fields are separated by commas.
Records are separated with system end of line characters, CRLF (ASCII 13 Dec or 0D Hex and ASCII 10 Dec or 0A Hex respectively) for Windows, LF for Unix, and CR for Mac.
For this application you need one jar file
That is : javacsv.jar


CSVReadExample.java


/**
* File Name : CSVReadExample.java
* Created By : Nagaraju V
* Created Date : Aug 06, 2009
* Purpose : Reading Data from CSV formated file
*/
package com.raj.csv;

import com.csvreader.CsvReader;

/**
* @author nagarajuv
*
*/
public class CSVReadExample {

public static void main(String arg[]) throws Exception {
CsvReader reader = new CsvReader("employees.csv");
reader.readHeaders();
System.out.println("EmpID \t EmpName \t Salary \t Age \t Experiance \t MobileNo");
while (reader.readRecord()) {
String EmpID = reader.get("EmpID");
String EmpName = reader.get("EmpName");
String Salary = reader.get("Salary");
String Age = reader.get("Age");
String Exp = reader.get("Exp");
String MobileNo = reader.get("MobileNo");

System.out.println(EmpID+"\t"+EmpName+"\t"+Salary+"\t"+Age+"\t"+Exp+"\t"+MobileNo);
}
reader.close();
}
}

The following source code contains the jar files and code. Enjoy with that example
Image Hosted by ImageShack.us
Image Hosted by ImageShack.us

Java Related Softwares

Friday, December 7, 2012


Java 1.5.0

With several new pure Java applications now available, Sun's Java 2 Runtime Environment is a necessary addition to your collection.


download



Tomcat Server

Tomcat is a web server here u can down load the 5.x, 6.x version of aphache and jakarta


apache-tomcat-6.0.13

jakarta-tomcat-5.0.25



Edit Plus

EditPlus is distributed as Shareware. You can download freely from here


editplust2.0