@Test
public void testCsvReadWrite() throws IOException, CsvParseException {

  File testFile = createTestCsv();
  List<Map<String, String>> data
          = Csv.read(testFile, StandardCharsets.UTF_8, new Csv.CsvHandler<List<Map<String, String>>>() {
            private boolean firstRow = true;
            private final List<Map<String, String>> result = new ArrayList<>();
            private List<String> header = new ArrayList<>();
            private Map<String, String> row = null;
            private int i = 0;
            @Override
            public void startRow() {
              if (!firstRow) {
                row = Maps.newHashMapWithExpectedSize(header.size());
                i = 0;
              }
            }
            @Override
            public void element(final CharSequence elem) {
              if (firstRow) {
                header.add(elem.toString());
              } else {
                row.put(header.get(i++), elem.toString());
              }
            }
            @Override
            public void endRow() {
              if (firstRow) {
                firstRow = false;
              } else {
                result.add(row);
              }
            }
            @Override
            public List<Map<String, String>> eof() {
              return result;
            }
          });
  Map<String, String> d0 = data.get(0);
  Assert.assertEquals("1,3", d0.get("c"));
  Assert.assertEquals("1", d0.get("d"));
  Map<String, String> d1 = data.get(1);
  Assert.assertEquals("1,3", d1.get("d"));
  Assert.assertEquals("\"", d1.get("b"));
  Assert.assertEquals("0\n", d1.get("c"));
}