Package org.encog.util.csv

Examples of org.encog.util.csv.ReadCSV


  }
 
  public void loadCSV(String filename, boolean headers, CSVFormat format, int[] input, int[] ideal) {
    // first, just size it up
    ReadCSV csv = new ReadCSV(filename,headers,format);
    int lineCount = 0;
    while(csv.next()) {
      lineCount++;
    }
    csv.close();
   
    // allocate space to hold it
    float[][] data = new float[input.length+ideal.length][lineCount];
   
    // now read the data in
    csv = new ReadCSV(filename,headers,format);
    int rowIndex = 0;
    while(csv.next()) {
      int columnIndex = 0;
     
      for(int i=0;i<input.length;i++) {
        data[columnIndex++][rowIndex] = (float)csv.getDouble(input[i]);
      }
      for(int i=0;i<ideal.length;i++) {
        data[columnIndex++][rowIndex] = (float)csv.getDouble(ideal[i]);
      }
     
      rowIndex++;
    }
    csv.close();
   
    // now add the columns
    for(int i=0;i<data.length;i++) {
      addColumn(data[i]);
    }
View Full Code Here


    if (this.inputCount == 0) {
      throw new BufferedDataError("To import CSV, you must use the "
          + "CSVDataCODEC constructor that specifies input and "
          + "ideal sizes.");
    }
    this.readCSV = new ReadCSV(this.file.toString(), this.headers,
        this.format);
  }
View Full Code Here

    try {
      final Collection<LoadedMarketData> result =
        new ArrayList<LoadedMarketData>();
      final URL url = buildURL(ticker, from, to);
      final InputStream is = url.openStream();
      final ReadCSV csv = new ReadCSV(is, true, CSVFormat.ENGLISH);

      while (csv.next()) {
        final Date date = csv.getDate("date");
        final double adjClose = csv.getDouble("adj close");
        final double open = csv.getDouble("open");
        final double close = csv.getDouble("close");
        final double high = csv.getDouble("high");
        final double low = csv.getDouble("low");
        final double volume = csv.getDouble("volume");

        final LoadedMarketData data =
          new LoadedMarketData(date, ticker);
        data.setData(MarketDataType.ADJUSTED_CLOSE, adjClose);
        data.setData(MarketDataType.OPEN, open);
        data.setData(MarketDataType.CLOSE, close);
        data.setData(MarketDataType.HIGH, high);
        data.setData(MarketDataType.LOW, low);
        data.setData(MarketDataType.OPEN, open);
        data.setData(MarketDataType.VOLUME, volume);
        result.add(data);
      }

      csv.close();
      is.close();
      return result;
    } catch (final IOException e) {
      throw new LoaderError(e);
    }
View Full Code Here

    analyst.addAnalystListener(new ConsoleAnalystListener());
    analyst.load(egaFile);

    analyst.executeTask("task-full");
   
    ReadCSV csv = new ReadCSV(outputFile.toString(),true,CSVFormat.ENGLISH);
    while(csv.next()) {
      double diff = Math.abs(csv.getDouble(2) - csv.getDouble(4));
      Assert.assertTrue(diff<1.5);
    }
   
    Assert.assertEquals(4, analyst.getScript().getFields().length );
    Assert.assertEquals(3, analyst.getScript().getFields()[3].getClassMembers().size());
   
    csv.close();
  }
View Full Code Here

    analyst.addAnalystListener(new ConsoleAnalystListener());
    analyst.load(egaFile);

    analyst.executeTask("task-full");
   
    ReadCSV csv = new ReadCSV(outputFile.toString(),true,CSVFormat.ENGLISH);
    while(csv.next()) {
      Assert.assertEquals(csv.get(3), csv.get(4));
    }
   
    Assert.assertEquals(4, analyst.getScript().getFields().length );
    Assert.assertEquals(3, analyst.getScript().getFields()[3].getClassMembers().size());
   
    csv.close();
  }
View Full Code Here

TOP

Related Classes of org.encog.util.csv.ReadCSV

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.