Skip to content
ybonnel edited this page Aug 14, 2012 · 3 revisions

In this page, you will find all informations about the usage of batch process in CsvEngine.

Just read the first lines of a CSV File

This code will just read the first two lines of the CSV File.

	List<Dog> dogs = engine.parseFirstLinesOfInputStream(getCsvFile(), Dog.class, 2).getObjects();

Read a CSV file by batch.

	engine.parseFileAndHandleBatch(new InputStreamReader(getCsvFile()), Dog.class, new InsertBatch<Dog>() {

	    int count = 1;

	    public void handleBatch(List<Dog> objects) {
	        System.out.println("Content of batch " + count);
	        for (Dog dog : objects) {
	            System.out.println(dog.toString());
	        }
	        count++;
	    }
	}, 2);

Samples

You can see samples in CsvEngineSample.

Clone this wiki locally