当前位置: 首页>>代码示例>>Java>>正文


Java CSVPrinter.print方法代码示例

本文整理汇总了Java中org.apache.commons.csv.CSVPrinter.print方法的典型用法代码示例。如果您正苦于以下问题:Java CSVPrinter.print方法的具体用法?Java CSVPrinter.print怎么用?Java CSVPrinter.print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.csv.CSVPrinter的用法示例。


在下文中一共展示了CSVPrinter.print方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toCSVLine

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
@Override
public void toCSVLine(CSVPrinter rec, Object obj) throws IOException {
	if(this.taxent == null) {
		rec.print("");
		return;
	}
	Map<String,InferredStatus> tStatus = this.inferNativeStatus();
	@SuppressWarnings("unchecked")
	List<String> allTerritories=(List<String>) obj;
	rec.print(this.taxent.getCurrent() ? "yes" : "no");
	rec.print(this.taxent.getID());
	rec.print((this.isLeaf ==null ? "" : (this.isLeaf ? "" : "+")) + this.taxent.getNameWithAnnotationOnly(false));
	rec.print(this.taxent.getAuthor());
	if(this.territories==null) return;

	for(String t : allTerritories) {
		if(tStatus.containsKey(t))
			rec.print(tStatus.get(t).getStatusSummary());
		else
			rec.print("");
	}
	rec.print(this.taxent.getComment());
}
 
开发者ID:miguel-porto,项目名称:flora-on-server,代码行数:24,代码来源:TaxEntAndNativeStatusResult.java

示例2: writeTo

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
public void writeTo(OutputStream outputStream) throws IOException {
  try (OutputStreamWriter osw = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {
    CSVPrinter csvPrinter = new CSVPrinter(osw, CSVFormat.DEFAULT);
    for (Object doc : docs) {
      if (doc instanceof Map) {
        Map<String,Object> map = (Map<String,Object>)doc;
        csvPrinter.printRecord(map.values());
      } else {
        csvPrinter.print(doc);
        csvPrinter.println();
      }
    }
    csvPrinter.flush();
    csvPrinter.close();
  }
}
 
开发者ID:lucidworks,项目名称:fusion-client-tools,代码行数:17,代码来源:FusionPipelineClient.java

示例3: toCSVLine

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
@Override
    public void toCSVLine(CSVPrinter rec, Object obj) throws IOException {
        TaxonomicPath taxonomicPath;
        taxonomicPath = new TaxonomicPath(this.higherTaxonomy);

        if (this.taxent == null) {
            rec.print("");
            return;
        }
//        rec.print(taxonomicPath.toString());
        TaxEnt tmp;
        for(Constants.TaxonRanks cf : Constants.CHECKLISTFIELDS) {
            if((tmp = taxonomicPath.getTaxonOfRank(cf)) == null)
                rec.print("");
            else
                rec.print(tmp.getFullName(false));
        }
        super.toCSVLine(rec, obj);
    }
 
开发者ID:miguel-porto,项目名称:flora-on-server,代码行数:20,代码来源:ChecklistEntry.java

示例4: print

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
public void print(String fileName) {
  try {
    BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
    CSVPrinter printer = new CSVPrinter(writer, CSVFormat.EXCEL);
    // print headers
    for (int i = 0; i < attributeConverters.size(); i++) {
      printer.print(this.attributeNames.get(i));
    }
    printer.println();
    // print rows
    for (UnosExchangeUnit unit : this.exchangeUnits) {

      if (nodeFilter.apply(unit)) {

        for (AttributeConverter<UnosExchangeUnit> converter : this.attributeConverters) {
          printer.print(converter.apply(unit));
        }
        printer.println();
      }
    }
    printer.flush();
    writer.close();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:27,代码来源:UnosInputSummary.java

示例5: writeData

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
public static void writeData(String path, String fileName, Iterable<Double> values){
	String fullFileName = path + fileName + csv;
	
	
	try {
		BufferedWriter writer = new BufferedWriter(new FileWriter(fullFileName));
		CSVPrinter printer = new CSVPrinter(writer, CSVFormat.EXCEL);
		for(Double value: values){
			printer.print(value.toString());
			printer.println();
		}
		printer.flush();
		writer.close();
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
	
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:19,代码来源:Queries.java

示例6: writeObjectHeader

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
private void writeObjectHeader(CSVPrinter outputStream) throws IOException {
    Field last = classFields.remove(classFields.size() - 1);
    for (Field field : classFields) {
       outputStream.print(getFieldName(field));
    }
    outputStream.print(getFieldName(last));
    outputStream.print('\n');
}
 
开发者ID:stoiandan,项目名称:OnlineShop,代码行数:9,代码来源:CSVProcessor.java

示例7: mapToCsv

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
/**
 * Map a ResultSet into the provided StringBuffer
 * in CSV format
 *
 * @param rs
 * @param additionalFields
 * @param ret
 * @throws IOException
 * @throws SQLException
 */
public void mapToCsv(ResultSet rs, Set<String> additionalFields, StringBuffer ret) throws IOException, SQLException {
    final CSVPrinter csvPrinter = new CSVPrinter(ret, csvFormat);


    //add titles
    for (int i=0;i<openDataFieldsSummary.length;i++) {
        csvPrinter.print(openDataFieldsSummary[i]);
    }

    //add additional Fields
    for (String additionalField : additionalFields) {
        csvPrinter.print(additionalField);
    }
    csvPrinter.println();


    //add values
    while (rs.next())
    {
        for (int i=0;i<openDataFieldsSummary.length;i++) {
            Object val = rs.getObject(openDataFieldsSummary[i]);
            csvPrinter.print(val);
        }
        if (additionalFields != null) {
            if (additionalFields.contains("download_classification")) {
                csvPrinter.print(Classification.classify(Classification.THRESHOLD_DOWNLOAD,rs.getLong("download_kbit"), 4));
            }
            if (additionalFields.contains("upload_classification")) {
                csvPrinter.print(Classification.classify(Classification.THRESHOLD_UPLOAD,rs.getLong("upload_kbit"), 4));
            }
            if (additionalFields.contains("ping_classification")) {
                csvPrinter.print(Classification.classify(Classification.THRESHOLD_PING,rs.getLong("ping_ms") * 1000000, 4));
            }
        }
        csvPrinter.println();
    }

    csvPrinter.flush();
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:50,代码来源:OpenTestSearchResource.java

示例8: tableToCsv

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
/**
 * Converts Guava table to a CSV table
 *
 * @param table                   table
 * @param csvFormat               CSV format
 * @param missingValuePlaceholder print if a value is missing (empty string by default)
 * @param <T>                     object type (string)
 * @return table
 * @throws IOException exception
 */
public static <T> String tableToCsv(Table<String, String, T> table, CSVFormat csvFormat,
        String missingValuePlaceholder)
        throws IOException
{
    StringWriter sw = new StringWriter();
    CSVPrinter printer = new CSVPrinter(sw, csvFormat);

    List<String> firstRow = new ArrayList<>();
    firstRow.add(" ");
    firstRow.addAll(table.columnKeySet());
    printer.printRecord(firstRow);

    for (String rowKey : table.rowKeySet()) {
        printer.print(rowKey);
        for (String columnKey : table.columnKeySet()) {
            T value = table.get(rowKey, columnKey);

            if (value == null) {
                printer.print(missingValuePlaceholder);
            }
            else {
                printer.print(value);
            }
        }
        printer.println();
    }

    printer.close();

    return sw.toString();
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:42,代码来源:TableUtils.java

示例9: convertTestCase

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
private void convertTestCase(TestCase testCase, CSVPrinter printer) throws IOException {
    Boolean clearOnExit = testCase.getTestSteps().isEmpty();
    testCase.loadTableModel();
    for (TestStep testStep : testCase.getTestSteps()) {
        if (testStep.isReusableStep()) {
            TestCase rTestCase = testCase.getProject()
                    .getScenarioByName(testStep.getReusableData()[0])
                    .getTestCaseByName(testStep.getReusableData()[1]);
            convertTestCase(rTestCase, printer);
        } else if (!testStep.getAction().isEmpty()) {
            printer.print(testCase.getScenario().getName());
            printer.print(testCase.getName());
            printer.print(testStep.getAction());
            CSVRecord descRecord = getRecordByAction(testStep.getAction());
            if (descRecord != null) {
                printer.print(resolve(testStep, descRecord.get("Description")));
                printer.print(resolve(testStep, descRecord.get("Expected Result")));
            } else {
                printer.print(resolve(testStep, MethodInfoManager.getDescriptionFor(testStep.getAction())));
                printer.print("");
            }
            printer.println();
        }
    }
    if (clearOnExit) {
        testCase.getTestSteps().clear();
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:29,代码来源:StepMap.java

示例10: printReport

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
void printReport(CSVPrinter csvPrinter, Set<SchemaEntity> schemaEntities) throws IOException {
  for (SchemaEntity entity : schemaEntities) {
    switch (entity.getSchemaEntityType()) {
      case NAMESPACE:
        namespaceReportString = entity.getNameAsString();
        tableReportString = "";
        colFamilyReportString = "";
        colQualifierReportString = "";
        colMaxLengthReportString = "";
        printReport(csvPrinter, entity.getChildren());
        break;
      case TABLE:
        tableReportString = entity.getNameAsString();
        printReport(csvPrinter, entity.getChildren());
        break;
      case COLUMN_FAMILY:
        colFamilyReportString = entity.getNameAsString();
        if (this.sourceColFamily != null
                && !colFamilyReportString.equals(Bytes.toString(sourceColFamily))) {
          continue;
        }
        printReport(csvPrinter, entity.getChildren());
        break;
      case COLUMN_AUDITOR:
        colQualifierReportString = entity.getNameAsString();
        colMaxLengthReportString = entity.getValue(ColumnAuditor.MAX_VALUE_LENGTH_KEY);
        csvPrinter.print(namespaceReportString);
        csvPrinter.print(tableReportString);
        csvPrinter.print(colFamilyReportString);
        csvPrinter.print(colQualifierReportString);
        csvPrinter.print(colMaxLengthReportString);
        csvPrinter.println();
        recordsWrittenToReport = true;
    }
  }
}
 
开发者ID:dvimont,项目名称:ColumnManagerForHBase,代码行数:37,代码来源:ColumnQualifierReport.java

示例11: dumpFeatures

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
public void dumpFeatures(List<FullyResolvedEntry> entries, FileProvider.FeatureSet output) throws IOException {
    FileWriter svmOutput = new FileWriter(output.SVMFeat);
    CSVPrinter csvPrinter = new CSVPrinter(new FileWriter(output.CSVFeat), CSVFormat.DEFAULT);
    CSVPrinter indexPrinter = new CSVPrinter(new FileWriter(output.index), CSVFormat.DEFAULT);

    for (FullyResolvedEntry entry : entries) {
        int order = 0;
        for (User user : entry.candidates) {
            indexPrinter.printRecord(entry.resource.getIdentifier(), user.getId(), user.getScreenName());
            boolean isPositive = user.getScreenName().equals(entry.entry.twitterId);
            double[] features = entry.features.get(order);

            csvPrinter.print(isPositive ? 1 : 0);
            svmOutput.write(String.valueOf(isPositive ? 1 : 0));
            for (int i = 0; i < features.length; i++) {
                csvPrinter.print(features[i]);
                svmOutput.write(" " + (i + 1) + ":");
                svmOutput.write(String.valueOf(features[i]));
            }
            svmOutput.write('\n');
            csvPrinter.println();
            order++;
        }
    }
    IOUtils.closeQuietly(svmOutput);
    indexPrinter.close();
    csvPrinter.close();
}
 
开发者ID:Remper,项目名称:sociallink,代码行数:29,代码来源:Evaluate.java

示例12: writeToStreamAndClose

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
/**
 * Helper that writes the given lines (adding a newline in between) to a stream, then closes the
 * stream.
 */
private static void writeToStreamAndClose(List<Object[]> rows, OutputStream outputStream) {
  try (PrintStream writer = new PrintStream(outputStream)) {
    CSVPrinter printer = CSVFormat.DEFAULT.print(writer);
    for (Object[] row : rows) {
      for (Object field : row) {
        printer.print(field);
      }
      printer.println();
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:18,代码来源:BeamTextCSVTableTest.java

示例13: getCSVHeader

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
@Override
public void getCSVHeader(CSVPrinter rec, Object obj) throws IOException {
	@SuppressWarnings("unchecked")
	List<String> territories=(List<String>) obj;
	rec.print("accepted");
	rec.print("id");
	rec.print("canonicalName");
	rec.print("authority");
	for(String t : territories) {
		rec.print(t);
	}
	rec.print("comment");
	rec.println();
}
 
开发者ID:miguel-porto,项目名称:flora-on-server,代码行数:15,代码来源:TaxEntAndNativeStatusResult.java

示例14: toCSVLine

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
@Override
public void toCSVLine(CSVPrinter rec, Object obj) throws IOException {
	// TODO obsolete!
	rec.print(this.count);
	rec.print(this.taxent.getID());
	rec.print(Arrays.toString(this.reltypes));
	rec.print((this.isLeaf ==null ? "" : (this.isLeaf ? "" : "+"))+(this.taxent.getCurrent() ? "" : "-")+this.taxent.getNameWithAnnotationOnly(false)+(this.partim ? " (partim)" : ""));
	rec.print(Arrays.toString(this.match));		// FIXME handle the array!
}
 
开发者ID:miguel-porto,项目名称:flora-on-server,代码行数:10,代码来源:SimpleTaxonResult.java

示例15: getCSVHeader

import org.apache.commons.csv.CSVPrinter; //导入方法依赖的package包/类
@Override
    public void getCSVHeader(CSVPrinter rec, Object obj) throws IOException {
//        rec.print("higherTaxonomy");
        for(Constants.TaxonRanks cf : Constants.CHECKLISTFIELDS)
            rec.print(cf.getName().toLowerCase());
        super.getCSVHeader(rec, obj);
    }
 
开发者ID:miguel-porto,项目名称:flora-on-server,代码行数:8,代码来源:ChecklistEntry.java


注:本文中的org.apache.commons.csv.CSVPrinter.print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。