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


Java CsvListWriter.close方法代码示例

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


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

示例1: flushTriples

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
public static InputStream flushTriples(Iterable<KiWiTriple> tripleBacklog) throws IOException {
    StringWriter out = new StringWriter();
    CsvListWriter writer = new CsvListWriter(out, CsvPreference.STANDARD_PREFERENCE);

    // reuse the same array to avoid unnecessary object allocation
    Object[] rowArray = new Object[10];
    List<Object> row = Arrays.asList(rowArray);

    for(KiWiTriple t : tripleBacklog) {
        rowArray[0] = t.getId();
        rowArray[1] = t.getSubject();
        rowArray[2] = t.getPredicate();
        rowArray[3] = t.getObject();
        rowArray[4] = t.getContext();
        rowArray[5] = t.getCreator();
        rowArray[6] = t.isInferred();
        rowArray[7] = t.isDeleted();
        rowArray[8] = t.getCreated();
        rowArray[9] = t.getDeletedAt();

        writer.write(row, tripleProcessors);
    }
    writer.close();

    return IOUtils.toInputStream(out.toString());
}
 
开发者ID:apache,项目名称:marmotta,代码行数:27,代码来源:MySQLLoadUtil.java

示例2: exportAll

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
@Override
public boolean exportAll(final Path file) {

    try {
        listWriter = new CsvListWriter(new FileWriter(file.toFile()), CsvPreference.STANDARD_PREFERENCE);

        // write the header
        listWriter.writeHeader(config.getHeaders());

        writeAnimeList();
        writeWatchList();
        writeFilterList();

        listWriter.close();
    } catch (final IOException e) {
        log.error("An error occurred while trying to export the list to CSV: ", e);
        return false;
    }

    return true;
}
 
开发者ID:manami-project,项目名称:manami,代码行数:22,代码来源:CsvExporter.java

示例3: writeTermMap

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
private void writeTermMap() throws IOException {
	BufferedWriter w = new BufferedWriter(new FileWriter(outputFile));
	CsvListWriter csvWriter = new CsvListWriter(w, MemeUtils.getCsvPreference());
	for (int rfBin = rfSize-1 ; rfBin >= 0 ; rfBin--) {
		List<String> columns = new ArrayList<String>(psSize);
		for (int psBin = 0 ; psBin < psSize ; psBin++) {
			if (termMap[psBin][rfBin] == null) {
				columns.add("");
			} else {
				columns.add(termMap[psBin][rfBin]);
			}
		}
		csvWriter.write(columns);
	}
	csvWriter.close();
}
 
开发者ID:tkuhn,项目名称:memetools,代码行数:17,代码来源:MakeTermMap.java

示例4: run

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
public void run() throws IOException {
	init();
	BufferedReader r = new BufferedReader(new FileReader(inputFile), 64*1024);
	CsvListReader csvReader = new CsvListReader(r, MemeUtils.getCsvPreference());
	BufferedWriter w = new BufferedWriter(new FileWriter(outputFile), 64*1024);
	CsvListWriter csvWriter = new CsvListWriter(w, MemeUtils.getCsvPreference());
	List<String> line = csvReader.read();
	int col;
	if (colIndexOrName.matches("[0-9]+")) {
		col = Integer.parseInt(colIndexOrName);
	} else {
		col = line.indexOf(colIndexOrName);
	}
	line.add(newColName);
	csvWriter.write(line);
	while ((line = csvReader.read()) != null) {
		if (line.get(col).matches(regex)) {
			line.add("1");
		} else {
			line.add("0");
		}
		csvWriter.write(line);
	}
	csvReader.close();
	csvWriter.close();
}
 
开发者ID:tkuhn,项目名称:memetools,代码行数:27,代码来源:ApplyRegex.java

示例5: processTerms

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
private void processTerms() throws IOException {
	log("Filtering and writing output...");
	int n = 0;
	Writer w = new BufferedWriter(new FileWriter(outputFile));
	CsvListWriter csvWriter = new CsvListWriter(w, MemeUtils.getCsvPreference());
	csvWriter.write("COUNT", "TERM");
	for (String term : ngrams.keySet()) {
		int c = ngrams.get(term);
		if (c >= t) {
			n++;
			logProgress(n);
			csvWriter.write(c, term);
		}
	}
	csvWriter.close();
	log("Number of n-grams after filtering: " + n);
}
 
开发者ID:tkuhn,项目名称:memetools,代码行数:18,代码来源:CountNgrams.java

示例6: writeCSVFile

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
public static void writeCSVFile(File file, List<List<String>> rows)
		throws IOException {
	StringWriter stringWriter = new StringWriter();
	CsvListWriter csvWriter = new CsvListWriter(stringWriter,
			CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE);

	for (List<String> list : rows) {
		csvWriter.write(list);
	}
	csvWriter.close();

	PrintWriter printWriter = new PrintWriter(file);
	printWriter.println(stringWriter.toString());
	stringWriter.close();
	printWriter.close();
}
 
开发者ID:GreenDelta,项目名称:olca-converter,代码行数:17,代码来源:ES2MappingFileUtil.java

示例7: CreateSparseNumericData

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
@Ignore("This is a test only for convenience")
@Test
public void CreateSparseNumericData() throws IOException
{
	FileWriter f = new FileWriter("SparseNumbersOnly.csv"); 
	CsvListWriter ff = new CsvListWriter(f, CsvPreference.STANDARD_PREFERENCE);
	
	final int rowsToProduce = 1000000;
	int j = 33;
	for(int i = 0; i < rowsToProduce; i++)
	{
		if(j == 0) j = 2;
		ff.write(i, i*j, i/(double)j);
		j = i*j % 1843;
	}
	ff.close();
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:18,代码来源:SparseDataCreator.java

示例8: flushTriples

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
public static void flushTriples(Iterable<KiWiTriple> tripleBacklog, OutputStream out) throws IOException {
    CsvListWriter writer = new CsvListWriter(new OutputStreamWriter(out), CsvPreference.STANDARD_PREFERENCE);

    // reuse the same array to avoid unnecessary object allocation
    Object[] rowArray = new Object[10];
    List<Object> row = Arrays.asList(rowArray);

    for(KiWiTriple t : tripleBacklog) {
        rowArray[0] = t.getId();
        rowArray[1] = t.getSubject();
        rowArray[2] = t.getPredicate();
        rowArray[3] = t.getObject();
        rowArray[4] = t.getContext();
        rowArray[5] = t.getCreator();
        rowArray[6] = t.isInferred();
        rowArray[7] = t.isDeleted();
        rowArray[8] = t.getCreated();
        rowArray[9] = t.getDeletedAt();

        writer.write(row, tripleProcessors);
    }
    writer.close();
}
 
开发者ID:apache,项目名称:marmotta,代码行数:24,代码来源:PGCopyUtil.java

示例9: write

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
public static synchronized String write(CsvWriter writer) {
  final StringWriter sw = new StringWriter();
  if(writer != null) {
    try {
      final CsvListWriter csv = new CsvListWriter(sw,
          CsvPreference.STANDARD_PREFERENCE);
      writer.write(csv);
      csv.close();
      return sw.toString();
    } catch(IOException e) {
      // How on earth would you get an IOException with a StringWriter?
      throw new RuntimeException(e);
    }
  } else {
    return null;
  }
}
 
开发者ID:uq-eresearch,项目名称:aorra,代码行数:18,代码来源:Csv.java

示例10: writeSuccessColumn

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
private void writeSuccessColumn() throws IOException {
	BufferedReader r = new BufferedReader(new FileReader(outputTempFile));
	CsvListReader csvReader = new CsvListReader(r, MemeUtils.getCsvPreference());
	Writer w = new BufferedWriter(new FileWriter(outputFile));
	CsvListWriter csvWriter = new CsvListWriter(w, MemeUtils.getCsvPreference());
	Writer wm = new BufferedWriter(new FileWriter(outputMatrixFile));
	CsvListWriter csvMatrixWriter = new CsvListWriter(wm, MemeUtils.getCsvPreference());

	// Process header:
	List<String> line = csvReader.read();
	line.add("CITATIONS-" + citationYears + "Y");
	csvWriter.write(line);
	line.remove(line.size()-2);
	line.remove(0);
	csvMatrixWriter.write(line);

	while ((line = csvReader.read()) != null) {
		String doi = line.get(0);
		long date = paperDates.get(doi);
		boolean completeRow = false;
		if (lastDay >= date + 365*citationYears) {
			line.add(paperCitations.get(doi).toString());
			completeRow = true;
		} else {
			line.add("-1");
		}
		csvWriter.write(line);
		if (completeRow) {
			line.remove(line.size()-2);
			line.remove(0);
			csvMatrixWriter.write(line);
		}
	}
	csvWriter.close();
	csvMatrixWriter.close();
	csvReader.close();
}
 
开发者ID:tkuhn,项目名称:memetools,代码行数:38,代码来源:CalculatePaperSuccess.java

示例11: run

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
public void run() throws IOException {
	init();

	loadTerms();

	int t = 0;
	log("Extracting terms from input file: " + inputFile);
	BufferedReader reader = new BufferedReader(new FileReader(inputFile));
	String line;
	while ((line = reader.readLine()) != null) {
		t++;
		logProgress(t);
		DataEntry d = new DataEntry(line);
		recordNgrams(d);
	}
	reader.close();
	log("Total number of documents: " + t);

	calculateMinMax();

	log("Writing output...");
	t = 0;
	File csvFile = new File(MemeUtils.getOutputDataDir(), getOutputFileName() + ".csv");
	Writer w = new BufferedWriter(new FileWriter(csvFile));
	CsvListWriter csvWriter = new CsvListWriter(w, MemeUtils.getCsvPreference());
	csvWriter.write("TERM", "MAX-ABS-DIFF", "MAX-REL-DIFF");
	for (String term : terms.keySet()) {
		logProgress(t);
		t++;
		double absFreqDiff = freqMax.get(term) - freqMin.get(term);
		double relFreqDiff = freqMax.get(term) / freqMin.get(term);
		csvWriter.write(term, absFreqDiff, relFreqDiff);
	}
	csvWriter.close();
	log("Finished");
}
 
开发者ID:tkuhn,项目名称:memetools,代码行数:37,代码来源:DetectJournalTerms.java

示例12: writeOutput

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
private void writeOutput() throws IOException {
	log("Writing result to output file...");
	if (outputFile == null) {
		outputFile = new File(MemeUtils.getOutputDataDir(), getOutputFileName() + ".csv");
	}
	CsvListWriter csvWriter = new CsvListWriter(new BufferedWriter(new FileWriter(outputFile)), MemeUtils.getCsvPreference());

	csvWriter.write("COMM-ID", "TIME-AVG", "MEME1", "FSCORE1", "MEME2", "FSCORE2", "...");

	for (String comm : communitySequence) {
		List<Object> row = new ArrayList<Object>();
		row.add(comm);
		row.add(timeSum.get(comm) / commFreq.get(comm));
		List<Pair<String,Float>> memes = new ArrayList<Pair<String,Float>>(commTopMemes.get(comm));
		Collections.sort(memes, new Comparator<Pair<String,Float>>() {
			@Override
			public int compare(Pair<String,Float> o1, Pair<String,Float> o2) {
				return o2.getRight().compareTo(o1.getRight());
			}
		});
		int n = 0;
		for (Pair<String,Float> m : memes) {
			n++;
			if (n > 3 && m.getRight() < 0.05) break;
			row.add(m.getLeft());
			row.add(m.getRight());
		}
		csvWriter.write(row);
	}

	csvWriter.close();
}
 
开发者ID:tkuhn,项目名称:memetools,代码行数:33,代码来源:CalculateCommData.java

示例13: run

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
public void run() throws IOException {
	init();
	BufferedReader r = new BufferedReader(new FileReader(inputFile), 64*1024);
	CsvListReader csvReader = new CsvListReader(r, MemeUtils.getCsvPreference());
	BufferedWriter w = new BufferedWriter(new FileWriter(outputFile), 64*1024);
	CsvListWriter csvWriter = new CsvListWriter(w, MemeUtils.getCsvPreference());
	List<String> header = csvReader.read();
	boolean[] textual = new boolean[header.size()];
	for (String t : textColums.split(",")) {
		if (t.isEmpty()) continue;
		if (t.matches("[0-9]+")) {
			textual[Integer.parseInt(t)] = true;
		} else {
			textual[header.indexOf(t)] = true;
		}
	}
	List<String> line;
	int c = 0;
	while ((line = csvReader.read()) != null) {
		c++;
		for (int i = 0 ; i < line.size() ; i++) {
			if (textual[i]) line.set(i, c + "");
		}
		csvWriter.write(line);
	}
	csvReader.close();
	csvWriter.close();
}
 
开发者ID:tkuhn,项目名称:memetools,代码行数:29,代码来源:MakeMatrix.java

示例14: run

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
public void run() throws IOException {
	init();
	BufferedReader r = new BufferedReader(new FileReader(inputFile), 64*1024);
	CsvListReader csvReader = new CsvListReader(r, MemeUtils.getCsvPreference());
	List<String> header = csvReader.read();
	int col;
	if (colIndexOrName.matches("[0-9]+")) {
		col = Integer.parseInt(colIndexOrName);
	} else {
		col = header.indexOf(colIndexOrName);
	}
	content.add(header);
	List<String> line;
	while ((line = csvReader.read()) != null) {
		double value = Double.parseDouble(line.get(col));
		if (uThreshold != null && value > uThreshold) continue;
		if (lThreshold != null && value < lThreshold) continue;
		sortList.add(Pair.of(content.size(), value));
		content.add(line);
	}
	csvReader.close();
	Collections.sort(sortList, new Comparator<Pair<Integer,Double>>() {
		@Override
		public int compare(Pair<Integer,Double> o1, Pair<Integer,Double> o2) {
			if (reversed) {
				return Double.compare(o2.getRight(), o1.getRight());
			} else {
				return Double.compare(o1.getRight(), o2.getRight());
			}
		}
	});
	BufferedWriter w = new BufferedWriter(new FileWriter(outputFile), 64*1024);
	CsvListWriter csvWriter = new CsvListWriter(w, MemeUtils.getCsvPreference());
	csvWriter.write(content.get(0));
	for (Pair<Integer,Double> p : sortList) {
		csvWriter.write(content.get(p.getLeft()));
	}
	csvWriter.close();
}
 
开发者ID:tkuhn,项目名称:memetools,代码行数:40,代码来源:SortTable.java

示例15: writeTable

import org.supercsv.io.CsvListWriter; //导入方法依赖的package包/类
private void writeTable() throws IOException {
	log("Writing CSV file...");
	Writer w = new BufferedWriter(new FileWriter(outputFile));
	CsvListWriter csvWriter = new CsvListWriter(w, MemeUtils.getCsvPreference());
	csvWriter.write("write", "something", "here");
	csvWriter.close();
}
 
开发者ID:tkuhn,项目名称:memetools,代码行数:8,代码来源:CalculateFMatrices.java


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