(
experiments: ExperimentReport[],
projectName: string,
)
| 56 | * @param projectName - The name of the project for the filename |
| 57 | */ |
| 58 | export function exportExperimentsToCsv( |
| 59 | experiments: ExperimentReport[], |
| 60 | projectName: string, |
| 61 | ): void { |
| 62 | const csvRows: string[] = []; |
| 63 | |
| 64 | // Add header row with exact field names |
| 65 | csvRows.push("experiment_id,name,emissions,energy_consumed,duration"); |
| 66 | |
| 67 | if (experiments && experiments.length > 0) { |
| 68 | experiments.forEach((exp) => { |
| 69 | csvRows.push( |
| 70 | `${exp.experiment_id},${exp.name},${exp.emissions},${exp.energy_consumed},${exp.duration}`, |
| 71 | ); |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | const csvString = csvRows.join("\n"); |
| 76 | const blob = new Blob([csvString], { type: "text/csv;charset=utf-8;" }); |
| 77 | downloadFile(blob, `${projectName.replace(/\s+/g, "_")}_experiments.csv`); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Export runs data to CSV format and initiate download |
no test coverage detected
searching dependent graphs…