简体   繁体   中英

export cloudsim output to an excel file

I have a cloudsim project and here is the output code, but this gives me a text file, i want my output in an excel file, is there anyway to do so? can anybody please help me with this? I have also attached the console output

private static void printCloudletList(List<Cloudlet> list) {
    int size = list.size();
    Cloudlet cloudlet;

    String indent = "    ";
    Log.printLine();
    Log.printLine("========== OUTPUT ==========");
    Log.printLine("Cloudlet ID" + indent + "STATUS" + indent +
            "Data center ID" + indent + "VM ID" + indent + indent + "Time" + indent + "Start Time" + indent + "Finish Time");

    DecimalFormat dft = new DecimalFormat("###.##");
    for (int i = 0; i < size; i++) {
        cloudlet = list.get(i);
        Log.print(indent + cloudlet.getCloudletId() + indent + indent);

        if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS){
            Log.print("SUCCESS");

            Log.printLine( indent + indent + cloudlet.getResourceId() + indent + indent + indent + cloudlet.getVmId() +
                    indent + indent + indent + dft.format(cloudlet.getActualCPUTime()) +
                    indent + indent + dft.format(cloudlet.getExecStartTime())+ indent + indent + indent + dft.format(cloudlet.getFinishTime()));
        }

在此处输入图片说明

Using CloudSim Plus you can generate results in CSV, open such a file in Excel and then save as XLS. The code is as below. CloudSim Plus even allows you to add any data you want to the generated table.

try {
    CsvTable csv = new CsvTable();
    csv.setPrintStream(new PrintStream(new java.io.File("/tmp/results.csv")));
    new CloudletsTableBuilder(broker0.getCloudletFinishedList(), csv).build();
} catch (IOException e) {
    System.err.println(e.getMessage());
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM