本文整理汇总了Java中com.opencsv.CSVWriter.NO_QUOTE_CHARACTER属性的典型用法代码示例。如果您正苦于以下问题:Java CSVWriter.NO_QUOTE_CHARACTER属性的具体用法?Java CSVWriter.NO_QUOTE_CHARACTER怎么用?Java CSVWriter.NO_QUOTE_CHARACTER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.opencsv.CSVWriter
的用法示例。
在下文中一共展示了CSVWriter.NO_QUOTE_CHARACTER属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialise
@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);
// Print the header
writer.writeNext(new String[] {
"Type",
"Subtype",
"Source type",
"Target type",
"Lemma",
"Lemma POS",
"Alternatives...."
});
}
示例2: save
/**
* <p>Saves the table values to the given file.</p>
* @param file
* @throws IOException
*/
public void save(File file) throws IOException {
CSVWriter writer = new CSVWriter(new FileWriter(file, true), CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER);
int rowCount = model.getRowCount();
int columnCount = model.getColumnCount();
for(int i = 0; i < rowCount; i++) {
String[] row = new String[columnCount];
for(int a = 0; a < columnCount; a++) {
row[a] = String.valueOf(model.getValueAt(i, a));
}
writer.writeNext(row);
}
writer.close();
}
示例3: doInitialize
@Override
public void doInitialize(UimaContext aContext) throws ResourceInitializationException {
super.doInitialize(aContext);
try {
// Attempt to create the path if it doesn't exist
new File(filename).getParentFile().mkdirs();
writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(filename, false), StandardCharsets.UTF_8), '\t', CSVWriter.NO_QUOTE_CHARACTER);
} catch (final IOException e) {
throw new ResourceInitializationException(e);
}
}
示例4: runTask
private boolean runTask() {
if (mAdapter == null || mAdapter.getCursor() == null)
return false;
// take cursor
Cursor data = mAdapter.getCursor();
// create object to write csv file
try {
CSVWriter csvWriter = new CSVWriter(new FileWriter(mFileName), CSVWriter.DEFAULT_SEPARATOR,
CSVWriter.NO_QUOTE_CHARACTER);
while (data.moveToNext()) {
String[] record = new String[7];
// compose a records
record[0] = data.getString(data.getColumnIndex(QueryAllData.UserDate));
if (!TextUtils.isEmpty(data.getString(data.getColumnIndex(QueryAllData.Payee)))) {
record[1] = data.getString(data.getColumnIndex(QueryAllData.Payee));
} else {
record[1] = data.getString(data.getColumnIndex(QueryAllData.AccountName));
}
record[2] = Double.toString(data.getDouble(data.getColumnIndex(QueryAllData.Amount)));
record[3] = data.getString(data.getColumnIndex(QueryAllData.Category));
record[4] = data.getString(data.getColumnIndex(QueryAllData.Subcategory));
record[5] = Integer.toString(data.getInt(data.getColumnIndex(QueryAllData.TransactionNumber)));
record[6] = data.getString(data.getColumnIndex(QueryAllData.Notes));
// writer record
csvWriter.writeNext(record);
// move to next row
data.moveToNext();
}
csvWriter.close();
} catch (Exception e) {
Timber.e(e, "exporting to CSV");
return false;
}
return true;
}
示例5: main
/**
* @param args yagoFacts.tsv file
* @throws IOException
* @throws FileNotFoundException
*/
public static void main(String[] args) throws IOException {
Preconditions.checkArgument(args.length == 1, "Usage: yagofactstomongo path/to/yagoFacts.tsv");
File yagoFactsTsvFile = new File(args[0]);
log.info("Importing '{}'...", yagoFactsTsvFile);
MongoClient mongo = new MongoClient(new MongoClientURI("mongodb://localhost/"));
DB db = mongo.getDB("lumen_lumen_dev");
DBCollection factColl = db.getCollection("fact");
log.info("Dropping fact collection...");
factColl.drop();
log.info("Fact collection dropped");
int factCount = 0;
try (CSVReader reader = new CSVReader(new FileReader(yagoFactsTsvFile), '\t', CSVWriter.NO_QUOTE_CHARACTER)) {
List<DBObject> dbos = new ArrayList<>();
while (true) {
String[] row = reader.readNext();
if (row == null || row.length == 0) {
break;
}
BasicDBObject dbo = new BasicDBObject(ImmutableMap.of(
//"_id", removeBrackets(row[0]),
"s", removeBrackets(row[1]),
"p", removeBrackets(row[2]),
"o", removeBrackets(row[3])));
dbos.add(dbo);
log.trace("Inserting {}...", dbo);
factCount++;
if (factCount % 10000 == 0) {
insert(factColl, dbos);
dbos.clear();
log.info("Inserted {} facts", factCount);
}
}
if (!dbos.isEmpty()) {
insert(factColl, dbos);
}
dbos.clear();
log.info("Inserted {} facts", factCount);
}
log.info("Imported {} facts", factCount);
log.info("Creating index...");
factColl.ensureIndex(new BasicDBObject("p", 1));
log.info("Index created");
}