My favorites | Sign in
Project Logo
                
Search
for
Updated Apr 17, 2009 by douglasjose
Labels: Featured
UsersGuide  
User's guide.

jCSVlib User's Guide

For more information, please refer to the project's Javadoc.

Basic Usage

Creating a CSV instance

Csv csv = CsvFactory.createOfficeCsv();

Data structure manipulation

csv.add(0, 0, "mydata");
csv.add(1, 1, "anotherdata");
String content = csv.get(1, 1);  // content = "anotherdata"
csv.remove(1, 1);
int i = csv.getColumns();        // i = 1
int j = csv.getRows();           // j = 1

Iterating over the structure

String content;
for (int i = 0; i < csv.getRows(); i++) {
    for (int j = 0; j < csv.getColumns(); j++) {
        content = csv.get(i, j);
        System.out.println(content);
    }
}

Reading a CSV file from disk

Csv csv = CsvFactory.createOfficeCsv();
InputStream is = new FileInputStream("SimpleCsv.csv");
csv.load(is);

Writing a CSV file to disk

Csv csv = CsvFactory.createOfficeCsv();
OutputStream os = new FileOutputStream("MyCsv.csv");
csv.store(os);

Advanced Features

Creating a thread-safe CSV implementation

Csv csv = CsvFactory.createOfficeCsv();
Csv syncCsv = CsvFactory.synchronizedCsv(csv);

Customizing CSV delimiters

// Using single quote as text delimiter and semi-colon as field separator
Csv customCsv = new BasicCsv(new CustomDelimitersCsvParser("'", ";"));

Sign in to add a comment
Hosted by Google Code