Java Code Examples for com.opencsv.CSVWriter#NO_QUOTE_CHARACTER

The following examples show how to use com.opencsv.CSVWriter#NO_QUOTE_CHARACTER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CsvInteractionWriter.java    From baleen with Apache License 2.0 6 votes vote down vote up
@Override
public void initialise() throws IOException {
  // Create the parent dirs
  new File(csvFilename).getAbsoluteFile().getParentFile().mkdirs();

  writer =
      new CSVWriter(
          new FileWriter(csvFilename, false),
          CSVWriter.DEFAULT_SEPARATOR,
          CSVWriter.NO_QUOTE_CHARACTER,
          CSVWriter.DEFAULT_ESCAPE_CHARACTER,
          CSVWriter.DEFAULT_LINE_END);

  // Print the header
  writer.writeNext(
      new String[] {
        "Type", "Subtype", "Source type", "Target type", "Lemma", "Lemma POS", "Alternatives...."
      });
}
 
Example 2
Source File: AddressServiceImpl.java    From axelor-open-suite with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public int export(String path) throws IOException {
  List<Address> addresses = addressRepo.all().filter("self.certifiedOk IS FALSE").fetch();

  CSVWriter csv =
      new CSVWriter(new java.io.FileWriter(path), "|".charAt(0), CSVWriter.NO_QUOTE_CHARACTER);
  List<String> header = new ArrayList<>();
  header.add("Id");
  header.add("AddressL1");
  header.add("AddressL2");
  header.add("AddressL3");
  header.add("AddressL4");
  header.add("AddressL5");
  header.add("AddressL6");
  header.add("CodeINSEE");

  csv.writeNext(header.toArray(new String[header.size()]));
  List<String> items = new ArrayList<>();
  for (Address a : addresses) {

    items.add(a.getId() != null ? a.getId().toString() : "");
    items.add(a.getAddressL2() != null ? a.getAddressL2() : "");
    items.add(a.getAddressL3() != null ? a.getAddressL3() : "");
    items.add(a.getAddressL4() != null ? a.getAddressL4() : "");
    items.add(a.getAddressL5() != null ? a.getAddressL5() : "");
    items.add(a.getAddressL6() != null ? a.getAddressL6() : "");
    items.add(a.getInseeCode() != null ? a.getInseeCode() : "");

    csv.writeNext(items.toArray(new String[items.size()]));
    items.clear();
  }
  csv.close();
  LOG.info("{} exported", path);

  return addresses.size();
}
 
Example 3
Source File: CsvTool.java    From axelor-open-suite with GNU Affero General Public License v3.0 4 votes vote down vote up
public static CSVWriter setCsvFile(final String filePath, final String fileName, char separator)
    throws IOException {

  java.io.Writer w = new FileWriter(filePath + File.separator + fileName);
  return new CSVWriter(w, separator, CSVWriter.NO_QUOTE_CHARACTER, "\r\n");
}