Examples of CSVDataSource


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

    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

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

        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

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

    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

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

      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

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

public class CSVDataSourceTest {
  private CSVDataSource source;

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

Examples of org.grouplens.lenskit.eval.data.CSVDataSource

    }

    private File trainingFile(TTDataSet data) throws IOException {
        try {
            GenericTTDataSet gds = (GenericTTDataSet) data;
            CSVDataSource csv = (CSVDataSource) gds.getTrainingData();
            if (",".equals(csv.getDelimiter())) {
                File file = csv.getFile();
                logger.debug("using training file {}", file);
                return file;
            }
        } catch (ClassCastException e) {
            /* No-op - this is fine, we will make a file. */
 
View Full Code Here

Examples of org.grouplens.lenskit.eval.data.CSVDataSource

        @Nullable
        @Override
        public File apply(@Nullable DataSource input) {
            assert input != null;
            if (input instanceof CSVDataSource) {
                CSVDataSource csv = (CSVDataSource) input;
                File file = csv.getFile();
                String name = file.getName();
                return new File(file.getParentFile(), name + ".pack");
            } else {
                File dir = new File(getProject().getConfig().getDataDir());
                dir = new File(dir, "packed");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.