Package org.supercsv.io

Examples of org.supercsv.io.ICsvBeanReader


         new ParseInt(),
         new ParseInt(),
         new StrMinMax(0, 10),
         new StrMinMax(0, 128)
      };
      ICsvBeanReader inFile = null;
      int count = 0;
      try {
         inFile = new CsvBeanReader(new FileReader(fileName), CsvPreference.EXCEL_PREFERENCE);
      } catch (FileNotFoundException ex) {
         errorMessage(fnfError, ex);
      }
      try {
         final String[] header = inFile.getCSVHeader(true);
         TermBean term;
         while ((term = inFile.read(TermBean.class, header, processors)) != null) {
            // add data to db
            processTerm(term, connection);
            count++;
         }
         JOptionPane.showMessageDialog(null, "Successfully imported " + count + " records from CSV file.");
      } catch (IOException ex) {
         errorMessage(readError, ex);
      } finally {
         try {
            inFile.close();
         } catch (IOException ex) {
            errorMessage(closeError, ex);
         }
      }
   }
View Full Code Here


     * @throws IOException
     *
     * @throws Exception
     */
    private ICsvBeanReader setup(String ticker, DateTime startDt, DateTime endDt) throws IOException {
        ICsvBeanReader beanReader = null;

        URL yahoo;
        StringBuffer urlStr = new StringBuffer(YAHOO_URL + ticker);
        /*if (startDt!=null && endDt !=null){
         //http://ichart.yahoo.com/table.csv?s=GOOG&a=0&b=1&c=2000&d=0&e=31&f=2010&g=w
         int startDtNumOfMonth = startDt.getMonthOfYear()-1;
         int startDtNumOfDay = startDt.getDayOfMonth();
         int startDtYear = startDt.getYear();

         int endDtNumOfMonth = endDt.getMonthOfYear()-1;
         int endDtNumOfDay = endDt.getDayOfMonth();
         int endDtYear = endDt.getYear();
         //url construction
         urlStr.append("&a=").append(startDtNumOfMonth);
         urlStr.append("&b=").append(startDtNumOfDay);
         urlStr.append("&c=").append(startDtYear);
         urlStr.append("&d=").append(endDtNumOfMonth);
         urlStr.append("&e=").append(endDtNumOfDay);
         urlStr.append("&f=").append(endDtYear);
         urlStr.append("&g=d&ignore=.csv");
         }*/
        yahoo = new URL(urlStr.toString());

        BufferedReader in = new BufferedReader(new InputStreamReader(
                yahoo.openStream()));

        beanReader = new CsvBeanReader(in, CsvPreference.STANDARD_PREFERENCE);
        beanReader.getHeader(true);

        return beanReader;

    }
View Full Code Here

            stock.setCompanyName(companyName);
            stock.setIsEnabled(isEnabled);
            stock.setLastUpdated(GameUtil.getCurrentTimeStamp());
            stock.setTicker(ticker);

            ICsvBeanReader beanReader = setup(ticker, null, null);
            if (beanReader == null) {
                play.Logger.warn("bean reader null");
            }

            List<StockPrice> stockPrices = parseCSV(beanReader);
View Full Code Here

        if (stockPrices == null || stockPrices.isEmpty()) {
            //just do a week at a time for performance reasons, hence 7 meaning 7 days
            DateTime fromDt = new DateTime(virtualDate.getTime());
            DateTime toDt = fromDt.plusDays(7);

            ICsvBeanReader beanReader = setup(ticker, fromDt, toDt);
            List<StockPrice> newStockPrices = parseCSV(beanReader);
            stock.getPrices().addAll(newStockPrices);
            stock.update();
            stockPrices = StockPrice.find.filter().eq("Date", virtualDate).filter(stock.getPrices());
        }
View Full Code Here

TOP

Related Classes of org.supercsv.io.ICsvBeanReader

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.