有办法将Cloudlet的输出保存到CSV文件吗?

huangapple 未分类评论43阅读模式
英文:

Is there a way to save Cloudlet output to a csv file?

问题

我正在使用CloudSim仿真工具进行硕士项目的开发。我想知道如何将printCloudletList的输出保存到NetBeans中的CSV文件中。有什么想法吗?请告诉我。

英文:

I'm working on a project using CloudSim simulation tool for masters. I want to know how to save the output of the printCloudletList to a csv file in NetBeans. Any ideas? Please let me know.

答案1

得分: 0

使用CloudSim Plus,您可以生成CSV和其他格式的结果。以下是代码部分。CloudSim Plus甚至允许您将任何想要添加到生成表中的数据添加进去。

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());
}
英文:

Using CloudSim Plus you can generate results in CSV and other formats. 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());
}

答案2

得分: 0

这段代码对我有效。只需在粘贴代码后进行一些导入操作。需要对输出的 CSV 文件进行一些最小的格式化,以便在 Excel 中正确显示。

英文:

The code here worked for me. Just had to do some imports after pasting in code. Needed some minimal formatting of outputted csv file to get it right in excel format.

huangapple
  • 本文由 发表于 2020年7月24日 14:18:41
  • 转载请务必保留本文链接:https://java.coder-hub.com/63067931.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定