North Concepts
home » data pipeline » examples » Specify lookup values programmatically

Specify lookup values programmatically

/*
* Copyright (c) 2006-2008 North Concepts Inc.  All rights reserved.
* Proprietary and Confidential.  Use is subject to license terms.
*
* http://northconcepts.com/data-pipeline/licensing/
*
*/
package com.northconcepts.datapipeline.examples.cookbook;

import java.io.File;

import com.northconcepts.datapipeline.core.DataReader;
import com.northconcepts.datapipeline.core.FieldList;
import com.northconcepts.datapipeline.core.StreamWriter;
import com.northconcepts.datapipeline.csv.CSVReader;
import com.northconcepts.datapipeline.job.JobTemplate;
import com.northconcepts.datapipeline.transform.TransformingReader;
import com.northconcepts.datapipeline.transform.lookup.BasicLookup;
import com.northconcepts.datapipeline.transform.lookup.LookupTransformer;

public class SpecifyLookupValuesProgrammatically {
   
   
public static void main(String[] args) throws Throwable {
       
DataReader reader = new CSVReader(new File("example/data/input/credit-balance-01.csv"))
           
.setFieldNamesInFirstRow(true);
       
       
// create a lookup that returns a field named 'rating_description'
       
BasicLookup lookup = new BasicLookup(
               
new FieldList().add("rating_description"));
       
        lookup.add
("A", "Class-A");
        lookup.add
("B", "Class-B");
        lookup.add
("C", "Class-C");
       
        TransformingReader transformingReader =
new TransformingReader(reader);
        transformingReader.add
(new LookupTransformer(
               
new FieldList().add("Rating")// use 'Rating' from example/data/input/credit-balance-01.csv
               
lookup
               
));
       
        JobTemplate.DEFAULT.transfer
(transformingReader, new StreamWriter(System.out));
   
}
   
}

back to examples index

Quick Links Documentation Contact
© 2007, 2008 North Concepts Inc.   All rights reserved.