Search in sources :

Example 1 with CSVFileSink

use of com.airhacks.enhydrator.out.CSVFileSink in project enhydrator by AdamBien.

the class FromJsonToCSVTest method fromJSONToCSV.

@Test
public void fromJSONToCSV() throws FileNotFoundException {
    Source source = new ScriptableSource(INPUT + "languages.json", INPUT + "converter.js", "UTF-8");
    final CSVFileSink csvFileSink = new CSVFileSink("*", getFileName(), ";", true, false);
    Pump pump = new Pump.Engine().from(source).to(new LogSink()).to(csvFileSink).build();
    pump.start();
}
Also used : LogSink(com.airhacks.enhydrator.out.LogSink) CSVFileSource(com.airhacks.enhydrator.in.CSVFileSource) Source(com.airhacks.enhydrator.in.Source) ScriptableSource(com.airhacks.enhydrator.in.ScriptableSource) VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) Pump(com.airhacks.enhydrator.Pump) ScriptableSource(com.airhacks.enhydrator.in.ScriptableSource) CSVFileSink(com.airhacks.enhydrator.out.CSVFileSink) Test(org.junit.Test)

Example 2 with CSVFileSink

use of com.airhacks.enhydrator.out.CSVFileSink in project enhydrator by AdamBien.

the class CsvCharsetTest method fromJSONToCSVWithCharset.

@Test
public void fromJSONToCSVWithCharset() throws FileNotFoundException {
    CSVFileSource source = new CSVFileSource(INPUT + "utf8-characters.csv", sourceDelimiter, sourceCharsetName, sourceContainsHeaders);
    String fileName = getFileName();
    final CSVFileSink csvFileSink = new CSVFileSink(sinkName, fileName, sinkDelimiter, sinkUseNamesAsHeaders, sinkAppend, "UTF-8");
    // do the test
    Pump pumpOut = new Pump.Engine().from(source).to(new LogSink()).to(csvFileSink).build();
    pumpOut.start();
}
Also used : LogSink(com.airhacks.enhydrator.out.LogSink) CSVFileSource(com.airhacks.enhydrator.in.CSVFileSource) Pump(com.airhacks.enhydrator.Pump) CSVFileSink(com.airhacks.enhydrator.out.CSVFileSink) Test(org.junit.Test)

Aggregations

Pump (com.airhacks.enhydrator.Pump)2 CSVFileSource (com.airhacks.enhydrator.in.CSVFileSource)2 CSVFileSink (com.airhacks.enhydrator.out.CSVFileSink)2 LogSink (com.airhacks.enhydrator.out.LogSink)2 Test (org.junit.Test)2 ScriptableSource (com.airhacks.enhydrator.in.ScriptableSource)1 Source (com.airhacks.enhydrator.in.Source)1 VirtualSinkSource (com.airhacks.enhydrator.in.VirtualSinkSource)1