Package com.csvreader

Examples of com.csvreader.CsvReader$RawRecordBuffer


  @Test
  public void test52() throws Exception {
    String data = "\\xfa\\u0afa\\xFA\\u0AFA";

    CsvReader reader = CsvReader.parse(data);
    reader.setUseTextQualifier(false);
    reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH);
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("\u00FA\u0AFA\u00FA\u0AFA", reader.get(0));
    Assert.assertEquals("\\xfa\\u0afa\\xFA\\u0AFA", reader.getRawRecord());
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here


  @Test
  public void test70() throws Exception {
    String data = "\"1\",Bruce\r\n\"2\",Toni\r\n\"3\",Brian\r\n";

    CsvReader reader = CsvReader.parse(data);
    reader.setHeaders(new String[] { "userid", "name" });
    Assert.assertEquals(2, reader.getHeaderCount());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get("userid"));
    Assert.assertEquals("Bruce", reader.get("name"));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(2, reader.getColumnCount());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("2", reader.get("userid"));
    Assert.assertEquals("Toni", reader.get("name"));
    Assert.assertEquals(1L, reader.getCurrentRecord());
    Assert.assertEquals(2, reader.getColumnCount());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("3", reader.get("userid"));
    Assert.assertEquals("Brian", reader.get("name"));
    Assert.assertEquals(2L, reader.getCurrentRecord());
    Assert.assertEquals(2, reader.getColumnCount());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

    Assert.assertEquals(expected.getMessage(), actual.getMessage());
  }

  @Test
  public void test1() throws Exception {
    CsvReader reader = CsvReader.parse("1,2");
    Assert.assertEquals("", reader.getRawRecord());
    Assert.assertEquals("", reader.get(0));
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals("2", reader.get(1));
    Assert.assertEquals(',', reader.getDelimiter());
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(2, reader.getColumnCount());
    Assert.assertEquals("1,2", reader.getRawRecord());
    Assert.assertFalse(reader.readRecord());
    Assert.assertEquals("", reader.getRawRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test2() throws Exception {
    String data = "\"bob said, \"\"Hey!\"\"\",2, 3 ";

    CsvReader reader = CsvReader.parse(data);
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("bob said, \"Hey!\"", reader.get(0));
    Assert.assertEquals("2", reader.get(1));
    Assert.assertEquals("3", reader.get(2));
    Assert.assertEquals(',', reader.getDelimiter());
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(3, reader.getColumnCount());
    Assert.assertEquals("\"bob said, \"\"Hey!\"\"\",2, 3 ", reader
        .getRawRecord());
    Assert.assertFalse(reader.readRecord());
    Assert.assertEquals("", reader.getRawRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test3() throws Exception {
    String data = ",";

    CsvReader reader = CsvReader.parse(data);
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("", reader.get(0));
    Assert.assertEquals("", reader.get(1));
    Assert.assertEquals(',', reader.getDelimiter());
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(2, reader.getColumnCount());
    Assert.assertEquals(",", reader.getRawRecord());
    Assert.assertFalse(reader.readRecord());
    Assert.assertEquals("", reader.getRawRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test4() throws Exception {
    String data = "1\r2";

    CsvReader reader = CsvReader.parse(data);
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.getRawRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("2", reader.get(0));
    Assert.assertEquals(1L, reader.getCurrentRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("2", reader.getRawRecord());
    Assert.assertFalse(reader.readRecord());
    Assert.assertEquals("", reader.getRawRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test5() throws Exception {
    String data = "1\n2";

    CsvReader reader = CsvReader.parse(data);
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.getRawRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("2", reader.get(0));
    Assert.assertEquals(1L, reader.getCurrentRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("2", reader.getRawRecord());
    Assert.assertFalse(reader.readRecord());
    Assert.assertEquals("", reader.getRawRecord());
    reader.close();
  }
View Full Code Here

    reader.close();
  }

  @Test
  public void test136() throws Exception {
    CsvReader reader = CsvReader.parse("1\n\n1\r\r1\r\n\r\n1\n\r1");
    Assert.assertTrue(reader.getSkipEmptyRecords());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(1L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(2L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(3L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(4L, reader.getCurrentRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

    reader.close();
  }

  @Test
  public void test137() throws Exception {
    CsvReader reader = CsvReader.parse("1;; ;1");
    reader.setRecordDelimiter(';');
    Assert.assertTrue(reader.getSkipEmptyRecords());
    reader.setSkipEmptyRecords(false);
    Assert.assertFalse(reader.getSkipEmptyRecords());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("", reader.get(0));
    Assert.assertEquals(1L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("", reader.get(0));
    Assert.assertEquals(2L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(3L, reader.getCurrentRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

    reader.close();
  }

  @Test
  public void test138() throws Exception {
    CsvReader reader = CsvReader.parse("1;; ;1");
    reader.setRecordDelimiter(';');
    Assert.assertTrue(reader.getSkipEmptyRecords());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("", reader.get(0));
    Assert.assertEquals(1L, reader.getCurrentRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals(1, reader.getColumnCount());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals(2L, reader.getCurrentRecord());
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

TOP

Related Classes of com.csvreader.CsvReader$RawRecordBuffer

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.