Package au.com.bytecode.opencsv

Examples of au.com.bytecode.opencsv.CSVReader.readNext()


        return null;
      }
      CSVReader reader = null;
      try {
        reader = this.createCSVReader(0);
        String[] header = reader.readNext();
        return header;
      } finally {
        if (reader != null) {
          try {
              reader.close();
View Full Code Here


        int maxCount = this.getConfig().getMaxRowCount();
        int i = 0;
        DataEntry dataEntry;
        Map<Integer, String> columnsMap = this.getConfig().getColumnMappings();
        boolean useColumnNumbers = this.isUsingColumnNumbers();     
        while ((record = reader.readNext()) != null) {
          if (maxCount != -1 && i >= maxCount) {
            break;
          }
          dataEntry = new DataEntry();
          for (int j = 0; j < record.length; j++) {
View Full Code Here

      reader = new CSVReader(new FileReader(file));

      // Use the first line to determine the type of csv file.  Secrets will
      // output 5 columns, with the names as used in the exportSecrets()
      // function.  OI Safe 1.1.0 is also detected.
      String headers[] = reader.readNext();
      if (null != headers) {
        isSecretsScv = isSecretsCsv(headers);
        if (!isSecretsScv)
          isOiSafeCsv = isOiSafeCsv(headers);
      }
View Full Code Here

          isOiSafeCsv = isOiSafeCsv(headers);
      }

      // Read all the rest of the lines as secrets.
      for (;;) {
        String[] row = reader.readNext();
        if (null == row)
          break;

        Secret secret = new Secret();
        if (isOiSafeCsv) {
View Full Code Here

      File dataDir = ((TvBrowserDataService) dataService).getWorkingDirectory();
      iconLoader = new IconLoader(TvBrowserDataService.getInstance(), mGroup.getId(), dataDir);
    }

    String[] tokens;
    while ((tokens = reader.readNext()) != null) {
      if (tokens.length < 4) {
        throw new FileFormatException("Syntax error in mirror file line " + lineCount + ": column count is '" + tokens.length + " < 4' : " + tokens[0]);
      }

      String country = null, timezone = null, id = null, name = null, copyright = null, webpage = null, iconUrl = null, categoryStr = null, unescapedname = null;
View Full Code Here

          PreparedStatement pstmt1 = dbconn.prepareStatement(statement1);
          pstmt1.executeUpdate();
        } catch (Exception e) {e.printStackTrace();}
        CSVReader cSVReader = new CSVReader(new InputStreamReader(in), ',', '"', 1);
        String [] nextLine;
        while ((nextLine = cSVReader.readNext()) != null) {
          System.out.println("read from CSV url: " + nextLine[0] + "," + nextLine[1] + "," + "etc...");
          String statement = "insert into compass.program_profile_info " +
              "(agency_name, program_name, program_type_code, program_type, " +
              "target_pop_a_code, target_pop_a_name, units_total, units_occupied, " +
              "units_available, contact_name, contact_phone, program_address_full, feed_source, update_time_stamp) " +
View Full Code Here

  public static List queryComputerBean() throws IOException {
    File csv = new File(Executions.getCurrent().getDesktop().getWebApp().getRealPath("/WEB-INF/xls/demo/data.csv"));
    CSVReader reader = new CSVReader(new FileReader(csv));
    List data = new ArrayList();
    String[] nextLine;
      while ((nextLine = reader.readNext()) != null) {
        ComputerBean computerBean = new ComputerBean();
        computerBean.setId(nextLine[0]);
        computerBean.setProduct(nextLine[1]);
        computerBean.setBrand(nextLine[2]);
        computerBean.setModel(nextLine[3]);
View Full Code Here

    System.out.println(httpResponse.body);
   
    System.out.println("-------Parsing with CSVReader------");
    CSVReader reader = new CSVReader(new StringReader(httpResponse.body));
      String[] line;
      while ((line = reader.readNext()) != null) {
        for (String col : line) {
          System.out.println("\t" + col);
        }
        System.out.println();
      }   
View Full Code Here

            vehicleDao.deleteAll();
            InputStreamReader r = new InputStreamReader( in );
            CSVReader reader = new CSVReader( r );
            String[] line;
            int cnt = 0;
            while( ( line = reader.readNext() ) != null ) {
                if( line.length > 0 ) {
                    Vehicle v = new Vehicle();
                    log.debug( "make: " + line[0]);
                    v.setVehicleMake( line[0]);
                    v.setVehicleModel( line[1]);
View Full Code Here

    systemMessages = new HashMap<Integer, String>(2500,0.9f);
    try {
      CSVReader reader = new CSVReader(new InputStreamReader(
          CSVDatastoreDAO.class.getResourceAsStream("/db/systemmessages.csv")), 1/*skip header*/, new CSVParser('\t','"','\\'));
     
      String[] line = reader.readNext();
     
      while (line != null) {
        if (line.length > 1) {
          systemMessages.put(Integer.valueOf(line[0]), line[1]);
        }
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.