Skip to content

Commit

Permalink
refactor: Update projectCsvUtils to use consistent capitalization for…
Browse files Browse the repository at this point in the history
… headers
  • Loading branch information
absternator committed Sep 6, 2024
1 parent 8d382ce commit 985258d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/client-v2/src/__tests__/utils/projectCsvUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("projectCsvUtils", () => {
const result = generateCsvContent(data);

expect(result).toBe(
"filename,Penicillin,cluster\nsample1,Penicillin-0.9,cluster1\nsample2,Penicillin-0.8,cluster2"
'filename,Penicillin,cluster\n"sample1","Penicillin-0.9","cluster1"\n"sample2","Penicillin-0.8","cluster2"'
);
});

Expand Down
6 changes: 3 additions & 3 deletions app/client-v2/src/utils/projectCsvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { convertProbabilityToWord } from "./amrDisplayUtils";

export const downloadCsv = (samples: ProjectSample[], filename: string) => {
const csvData = samples.map((sample) => ({
filename: sample.filename,
Filename: sample.filename,
...(sample.amr && convertAmrForCsv(sample.amr)),
cluster: sample.cluster || "run for cluster assignment"
Cluster: sample.cluster || ""
}));

const csvContent = generateCsvContent(csvData);
Expand All @@ -24,7 +24,7 @@ export const generateCsvContent = (data: Record<string, string>[]) => {
if (data.length === 0) return "";

const headers = Object.keys(data[0]);
const rows = data.map((row) => headers.map((header) => row[header] || "").join(","));
const rows = data.map((row) => headers.map((header) => `"${row[header]}"`).join(","));
return [headers.join(","), ...rows].join("\n");
};

Expand Down

0 comments on commit 985258d

Please sign in to comment.