Package com.csvreader

Examples of com.csvreader.CsvReader$RawRecordBuffer


    reader.close();
  }

  @Test
  public void test143() throws Exception {
    CsvReader reader = CsvReader.parse("\"" + generateString('a', 100001)
        + "\"");
    try
    {
      reader.readRecord();
    }
    catch (Exception ex)
    {
      assertException(new IOException("Maximum column length of 100,000 exceeded in column 0 in record 0. Set the SafetySwitch property to false if you're expecting column lengths greater than 100,000 characters to avoid this error."), ex);
    }
    reader.close();
  }
View Full Code Here


  @Test
  public void test6() throws Exception {
    String data = "1\r\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

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

    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.assertFalse(reader.readRecord());
    Assert.assertEquals("", reader.getRawRecord());
    reader.close();
  }
View Full Code Here

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

    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.assertFalse(reader.readRecord());
    Assert.assertEquals("", reader.getRawRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test9() throws Exception {
    String data = "1\r\n";

    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.assertFalse(reader.readRecord());
    Assert.assertEquals("", reader.getRawRecord());
    reader.close();
  }
View Full Code Here

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

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

  @Test
  public void test11() throws Exception {
    String data = "\"July 4th, 2005\"";

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

  @Test
  public void test12() throws Exception {
    String data = " 1";

    CsvReader reader = CsvReader.parse(data);
    reader.setTrimWhitespace(false);
    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.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

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

    CsvReader reader = CsvReader.parse(data);
    Assert.assertFalse(reader.readRecord());
    reader.close();
  }
View Full Code Here

  @Test
  public void test14() throws Exception {
    String data = "user_id,name\r\n1,Bruce";

    CsvReader reader = CsvReader.parse(data);
    Assert.assertTrue(reader.readHeaders());
    Assert.assertEquals("user_id,name", reader.getRawRecord());
    Assert.assertTrue(reader.readRecord());
    Assert.assertEquals("1", reader.get(0));
    Assert.assertEquals("Bruce", reader.get(1));
    Assert.assertEquals(0L, reader.getCurrentRecord());
    Assert.assertEquals(2, reader.getColumnCount());
    Assert.assertEquals(0, reader.getIndex("user_id"));
    Assert.assertEquals(1, reader.getIndex("name"));
    Assert.assertEquals("user_id", reader.getHeader(0));
    Assert.assertEquals("name", reader.getHeader(1));
    Assert.assertEquals("1", reader.get("user_id"));
    Assert.assertEquals("Bruce", reader.get("name"));
    Assert.assertEquals("1,Bruce", reader.getRawRecord());
    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.