Package no.priv.garshol.duke.datasources

Examples of no.priv.garshol.duke.datasources.CSVDataSource$CSVRecordIterator


    File tstfile = tmpdir.newFile("testfile.csv");
    out = new FileWriter(tstfile);
    out.close();

    CSVDataSource csv = new CSVDataSource();
    csv.setSeparator(';');
    csv.setInputFile(outfile.getAbsolutePath());
    csv.addColumn(new Column("id", null, null, null));
    csv.addColumn(new Column("name", null, null, null));
    csv.addColumn(new Column("age", null, null, null));

    ConfigurationImpl cfg = new ConfigurationImpl();
    cfg.addDatabase(new InMemoryDatabase());
    cfg.addDataSource(0, csv);
View Full Code Here


        if (attributes.getValue("lookup") != null)
          lookup = (Property.Lookup) ObjectUtils.getEnumConstantByName(
                                Property.Lookup.class,
                                attributes.getValue("lookup").toUpperCase());
      } else if (localName.equals("csv")) {
        datasource = new CSVDataSource();
        currentobj = datasource;
      } else if (localName.equals("jdbc")) {
        datasource = new JDBCDataSource();
        currentobj = datasource;
      } else if (localName.equals("jndi")) {
View Full Code Here

    Configuration config = new ConfigurationImpl();
    ((ConfigurationImpl) config).setProperties(props);
    ((ConfigurationImpl) config).setThreshold(0.85);
    ((ConfigurationImpl) config).setMaybeThreshold(0.7);

    CSVDataSource csv = new CSVDataSource();
    csv.setInputFile("test.csv");
    csv.addColumn(new Column("id", "ID", null, null));
    csv.addColumn(new Column("name", "NAME", null, null));
    Column emailCol = new Column("email", "EMAIL", null, null);
    emailCol.setSplitOn(";");
    csv.addColumn(emailCol);
    ((ConfigurationImpl) config).addDataSource(0, csv);
   
    // --- write and reload
    File outfile = tmpdir.newFile("config.xml");           
    ConfigWriter.write(config, outfile.getAbsolutePath());
    config = ConfigLoader.load(outfile.getAbsolutePath());
   
    // --- verify loaded correctly   
    assertEquals(1, config.getDataSources().size());

    csv = (CSVDataSource) config.getDataSources().iterator().next();
    assertTrue(csv.getInputFile().endsWith("test.csv"));
    assertEquals(3, csv.getColumns().size());
    Collection<Column> csvEmailColList = csv.getColumn("email");
    Column csvEmailCol = (Column) csvEmailColList.toArray()[0];
    assertTrue(csvEmailCol.isSplit());
    // FIXME: check the columns (kind of hard given lack of ordering)
   
    assertTrue(config.getDataSources(1).isEmpty());
View Full Code Here

      writeParam(pp, "collection", mongodb.getCollection());
      writeParam(pp, "query", mongodb.getQuery());
      writeParam(pp, "projection", mongodb.getProjection());
    } else if (src instanceof CSVDataSource) {
      name = "csv";
      CSVDataSource csv = (CSVDataSource) src;
      pp.startElement(name, null);

      writeParam(pp, "input-file", csv.getInputFile());
      writeParam(pp, "encoding", csv.getEncoding());
      writeParam(pp, "skip-lines", csv.getSkipLines());
      writeParam(pp, "header-line", csv.getHeaderLine());
      if (csv.getSeparator() != 0)
        writeParam(pp, "separator", csv.getSeparator());
    } else if (src instanceof SparqlDataSource) {
      name = "sparql";
      SparqlDataSource sparql = (SparqlDataSource) src;
      pp.startElement(name, null);
View Full Code Here

public class CSVDataSourceTest {
  private CSVDataSource source;

  @Before
  public void setup() {
    source = new CSVDataSource();
  }
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.datasources.CSVDataSource$CSVRecordIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.