use of org.supercsv.io.ICsvMapWriter in project photon-model by vmware.
the class TestUtils method writeCsvToFile.
/**
* Write the updated data back to the CSV
*/
private static void writeCsvToFile(List<Map<String, Object>> rows, Path csvBillZipFilePath) throws Exception {
String unzippedCsvFilePathStr = csvBillZipFilePath.toString().substring(0, csvBillZipFilePath.toString().lastIndexOf('.'));
ICsvMapWriter listWriter = null;
try {
listWriter = new CsvMapWriter(new FileWriter(unzippedCsvFilePathStr), CsvPreference.STANDARD_PREFERENCE);
// the header elements are used to map the bean values to each column (names must match)
final String[] header = new String[] { "InvoiceID", "PayerAccountId", "LinkedAccountId", "RecordType", "RecordId", "ProductName", "RateId", "SubscriptionId", "PricingPlanId", "UsageType", "Operation", "AvailabilityZone", "ReservedInstance", "ItemDescription", "UsageStartDate", "UsageEndDate", "UsageQuantity", "BlendedRate", "BlendedCost", "UnBlendedRate", "UnBlendedCost", "ResourceId", "user:Description", "user:Geo", "user:Name", "user:testTag", "user:testTag2" };
listWriter.writeHeader(header);
for (Map<String, Object> row : rows) {
listWriter.write(row, header);
}
} finally {
if (listWriter != null) {
listWriter.close();
}
}
}
use of org.supercsv.io.ICsvMapWriter in project jprime by bgjug.
the class CSVService method exportSubmissions.
public File exportSubmissions(List<Submission> submissions) throws IOException {
File submissionsCSVFile = File.createTempFile("submissions.", ".csv");
logger.info("Created submissions file with path: " + submissionsCSVFile.getAbsolutePath());
try (ICsvMapWriter mapWriter = new CsvMapWriter(new FileWriter(submissionsCSVFile.getAbsolutePath()), CsvPreference.STANDARD_PREFERENCE)) {
writeSubmissions(submissions, mapWriter);
}
return submissionsCSVFile;
}
use of org.supercsv.io.ICsvMapWriter in project webofneeds by researchstudio-sat.
the class SimonCsvStatisticsRecorder method recordMonitoringStatistics.
@Override
public void recordMonitoringStatistics() {
ICsvMapWriter mapWriter = null;
try {
mapWriter = new CsvMapWriter(new FileWriter(createOutFileObject()), CsvPreference.STANDARD_PREFERENCE);
final CellProcessor[] processors = getProcessors();
// write the header
mapWriter.writeHeader(header);
// create a simon visitor that writes each line
SimonVisitor visitor = new CsvSimonVisitor(mapWriter);
// write the customer maps
SimonVisitors.visitTree(SimonManager.getRootSimon(), visitor);
} catch (IOException e) {
logger.warn("could not write simon statistics", e);
} finally {
if (mapWriter != null) {
try {
mapWriter.close();
} catch (IOException e) {
logger.warn("could not close writer", e);
}
}
}
}
Aggregations