Package au.com.bytecode.opencsv

Examples of au.com.bytecode.opencsv.CSVParser


  Schema schema;
  List<Schema.Field> curFields;
  String headerHash;
 
  public CSVRowParser(Schema schema, String headerHash) {
    this.parser = new CSVParser();
    this.schema = schema;
    this.curFields = schema.getFields();
    this.headerHash = headerHash;
  }
View Full Code Here


     * @param separator Character separator for the data received.
     */
    public RowParser(TableSchema schema, String[] columns, char separator) {
        this.schema = schema;
        this.columns = columns;
        this.csvParser = new CSVParser(separator);
    }
View Full Code Here

   * @param parser
   * @param headers
   * @return
   */
  public static CSVToContextPreparator create(Configuration configuration) {
    CSVParser parser = new CSVParser();

    String headerString = configuration
        .get(JobConfigurationConstants.HEADER_STRING);
    String columnFamily = configuration
        .get(JobConfigurationConstants.COLUMN_FAMILY);
View Full Code Here

  /**
   * @throws java.lang.Exception
   */
  @BeforeMethod
  public void setUp() throws Exception {
    preparator = new CSVToContextPreparator(new CSVParser(),
        new HBaseKeyGenerator(""), anyColumnFamily, Arrays.asList(anyQualifier));
  }
View Full Code Here

  public void prepareForContext_columnFamilyAndQualifier_customColumnFamilyAndQualifier()
      throws IOException {
    String customFamily = "columnFamily";
    String customQualifier = "qualifier";
    CSVToContextPreparator contextPreparator = new CSVToContextPreparator(
        new CSVParser(), new HBaseKeyGenerator(""), customFamily,
        Arrays.asList(customQualifier));

    List<KeyValue> result = contextPreparator.prepareForContext(anyKey,
        "value1,value2");
   
View Full Code Here

  @Test(expectedExceptions = Exception.class)
  public void getHeaders_headerRowContainingEmptyHeaderName_castsException()
      throws Exception {
    String stringContainingRowWithEmptyHeaderName = "header1,,header3,header4";

    new HeaderGetter(new CSVParser(),
        stringContainingRowWithEmptyHeaderName).getHeaders();

  }
View Full Code Here

  @Test(expectedExceptions = RuntimeException.class)
  public void getHeaders_emptyHeaderRow_throwsException() throws Exception {
    String stringWithEmptyHeader = "";

    new HeaderGetter(new CSVParser(), stringWithEmptyHeader)
        .getHeaders();
  }
View Full Code Here

  public void getHeaders_twoHeadersZeroValueRows_arrayWithTwoStrings()
      throws Exception {
    String headerString = "header1,header2";

    List<String> headers = new HeaderGetter(new CSVParser(), headerString)
        .getHeaders();

    assertEquals(2, headers.size());
    assertEquals("header1", headers.get(0));
    assertEquals("header2", headers.get(1));
View Full Code Here

  /**
   * @param is The input stream to load
   */
  public void initializeFromStream(InputStream is) throws IOException {
    CSVParser parser = new CSVParser();
    BufferedReader r = new BufferedReader(new InputStreamReader(is));
    String line = r.readLine();
    while (line != null) {
      String[] fields = parser.parseLine(line);
      if (fields.length != 3) {
        s_logger.warn("Line {} not in proper format.", line);
      } else {
        String scheme = fields[0];
        String id = fields[1];
View Full Code Here

TOP

Related Classes of au.com.bytecode.opencsv.CSVParser

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.