Examples of CSVReader


Examples of au.com.bytecode.opencsv.CSVReader

            throw new UnsupportedOperationException(
                "A stream from an export endpoint is not supported " +
                "by a CSV result reader. Use XML or JSON search output "+
                "format and matching reader instead."
            );
        csvReader = new CSVReader(new InputStreamReader(inputStream, "UTF-8"));
        // initial line contains the keyArray, except for oneshot -- which
        // contains a blank line, and then the key list.
        String[] keyArray = csvReader.readNext();
        if (keyArray.length == 1 && keyArray[0].trim().equals("")) {
            keyArray = csvReader.readNext();
View Full Code Here

Examples of au.com.bytecode.opencsv.CSVReader

    }
  }

  private static void parseResults(InputStream in, SearchResultListener srl)
      throws IOException {
    CSVReader csvr = new CSVReader(new InputStreamReader(in));
    try {
      String [] header = csvr.readNext();

      if (header != null
          && header.length > 0
          && !(header.length == 1 && header[0].isEmpty())) {
        srl.setFieldNames(header);

        String[] line;
        while ((line = csvr.readNext()) != null) {
          if (line.length == header.length) {
            srl.processSearchResult(line);
          }
        }
      }
View Full Code Here

Examples of au.com.bytecode.opencsv.CSVReader

     * </ul>
     */
    private int source;

    public SplunkResultEnumerator(InputStream in, List<String> wantedFields) {
      csvReader = new CSVReader(new InputStreamReader(in));
      try {
        fieldNames = csvReader.readNext();
        if (fieldNames == null
            || fieldNames.length == 0
            || fieldNames.length == 1 && fieldNames[0].isEmpty()) {
View Full Code Here

Examples of au.com.bytecode.opencsv.CSVReader

     * @return CSVReader, must call {@link CSVReader#close()} to free FileReader
     * @throws FileNotFoundException
     */
    public CSVReader reader() throws IOException {
        Reader fileReader = new FileReader( file );
        CSVReader reader = new CSVReader(fileReader);
        String row[] = reader.readNext();
        if( header == null ){
            setHeader(row);
        }
        return reader;
    }
View Full Code Here

Examples of au.com.bytecode.opencsv.CSVReader

    /** Calculate the size of the file */
    public synchronized int getSize(){
        if( size == -1 ){
            size = 0;
            try {
                CSVReader reader = reader();
                String row[] = reader.readNext(); // skip headers!
                while ((row = reader.readNext()) != null) {
                    size++;
                }
            }
            catch (IOException eek){
                eek.printStackTrace();
View Full Code Here

Examples of au.com.bytecode.opencsv.CSVReader

        if (monitor == null)
            monitor = new NullProgressMonitor();

        monitor.beginTask("csv render", 100);

        CSVReader reader = null;
        try {
            g.setColor(Color.BLACK);
            ILayer layer = getContext().getLayer();
            IGeoResource resource = layer.findGeoResource(CSV.class);
            if (resource == null)
                return;

            CoordinateReferenceSystem dataCRS = layer.getCRS();
            CoordinateReferenceSystem worldCRS = context.getCRS();
            MathTransform dataToWorld = CRS.findMathTransform(dataCRS, worldCRS, false);

            ReferencedEnvelope bounds = getRenderBounds();
            monitor.subTask("connecting");
           
            CSV csv = resource.resolve(CSV.class, new SubProgressMonitor(monitor, 10) );
            reader = csv.reader();
           
            int nameIndex = csv.getHeader("name");

            IProgressMonitor drawMonitor = new SubProgressMonitor(monitor, 90);
            Coordinate worldLocation = new Coordinate();
           
            drawMonitor.beginTask("draw "+csv.toString(), csv.getSize());           
            String [] row;
            while ((row = reader.readNext()) != null) {
                Point point = csv.getPoint(row);
                Coordinate dataLocation = point.getCoordinate();
                try {
                    JTS.transform(dataLocation, worldLocation, dataToWorld);
                } catch (TransformException e) {
                    continue;
                }               
                if (bounds != null && !bounds.contains(worldLocation)) {
                    continue; // optimize!
                }               
                java.awt.Point p = getContext().worldToPixel(worldLocation);
                g.fillOval(p.x, p.y, 10, 10);
                String name = row[nameIndex];
                g.drawString(name, p.x + 15, p.y + 15);
                drawMonitor.worked(1);

                if (drawMonitor.isCanceled())
                    break;
            }
            drawMonitor.done();           
        } catch (IOException e) {
            throw new RenderException(e); // rethrow any exceptions encountered
        } catch (FactoryException e) {
            throw new RenderException(e); // rethrow any exceptions encountered
        } finally {
            if (reader != null)
                try {
                    reader.close();
                } catch (IOException e) {
                    throw new RenderException(e);
                }
            monitor.done();
        }
View Full Code Here

Examples of au.com.bytecode.opencsv.CSVReader

    public void render_example( Graphics2D g, IProgressMonitor monitor ) throws RenderException {
        if (monitor == null)
            monitor = new NullProgressMonitor();

        monitor.beginTask("csv render", IProgressMonitor.UNKNOWN);
        CSVReader reader = null;
        try {
            g.setColor(Color.BLUE);

            ILayer layer = getContext().getLayer();
            IGeoResource resource = layer.findGeoResource(CSV.class);
            if (resource == null)
                return;

            ReferencedEnvelope bounds = getRenderBounds();
            monitor.subTask("connecting");

            CSV csv = resource.resolve(CSV.class, new SubProgressMonitor(monitor, 10));
            reader = csv.reader();
           
            monitor.subTask("drawing");
            int nameIndex = csv.getHeader("name");
            Coordinate worldLocation = new Coordinate();
            String [] row;
            while ((row = reader.readNext()) != null) {
                Point point = csv.getPoint(row);
                worldLocation = point.getCoordinate();
                if (bounds != null && !bounds.contains(worldLocation)) {
                    continue; // optimize!
                }
                java.awt.Point p = getContext().worldToPixel(worldLocation);
                g.fillOval(p.x, p.y, 10, 10);
                String name = row[nameIndex];
                g.drawString(name, p.x + 15, p.y + 15);
                monitor.worked(1);

                if (monitor.isCanceled())
                    break;
            }
        } catch (IOException e) {
            throw new RenderException(e); // rethrow any exceptions encountered
        } finally {
            if (reader != null)
                try {
                    reader.close();
                } catch (IOException e) {
                    throw new RenderException(e); // rethrow any exceptions encountered
                }
            monitor.done();
        }
View Full Code Here

Examples of au.com.bytecode.opencsv.CSVReader

    CSVGeoResource handle;
    public CSVGeoResourceInfo( CSVGeoResource resource, IProgressMonitor monitor ) throws IOException {
        this.handle = resource;
        this.title = handle.getIdentifier().toString();
        CSV csv = handle.getCSV( monitor );
        CSVReader reader = csv.reader();
        try {
            this.description = "Information:";
            for( String header : csv.getHeader() ){
                this.description += " "+header;
            }
            this.bounds = new ReferencedEnvelope(DefaultGeographicCRS.WGS84);
           
            String row[];
            while ((row = reader.readNext()) != null) {
                Point point = csv.getPoint( row );
                if( point == null ) {
                    continue; // what is the point
                }
                this.bounds.expandToInclude(point.getCoordinate());
            }
        }
        finally {
            reader.close();
        }
    }
View Full Code Here

Examples of com.asakusafw.utils.io.csv.CsvReader

    }

    private List<List<String>> parse(String contents) {
        try {
            List<List<String>> results = new ArrayList<List<String>>();
            CsvReader reader = new CsvReader(new StringReader(contents));
            while (reader.next()) {
                results.add(reader.get());
            }
            return results;
        } catch (Exception e) {
            throw new AssertionError(e);
        }
View Full Code Here

Examples of com.asakusafw.utils.io.csv.CsvReader

                }
            } finally {
                sink.close();
            }

            CsvReader reader = new CsvReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
            try {
                Map<YaessJobId, List<String>> results = new HashMap<YaessJobId, List<String>>();
                assertThat("skip header", reader.next(), is(true));
                while (reader.next()) {
                    List<String> record = reader.get();
                    YaessJobId id = new YaessJobId();
                    id.setBatchId(record.get(0));
                    id.setFlowId(record.get(1));
                    id.setExecutionId(record.get(2));
                    id.setPhase(record.get(3));
                    id.setServiceId(record.get(4));
                    id.setJobId(record.get(5));
                    id.setTrackingId(record.get(6));
                    assertThat(results.get(id), is(nullValue()));
                    results.put(id, new ArrayList<String>(record.subList(7, record.size())));
                }
                return results;
            } finally {
                reader.close();
            }
        } catch (Exception e) {
            throw new AssertionError(e);
        }
    }
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.