Skip to content

Commit

Permalink
🔨 incorporate PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Dec 3, 2024
1 parent 6f42518 commit ff311ee
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions packages/@ourworldindata/core-table/src/OwidTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,30 +607,25 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {

// Give our users a clean CSV of each Grapher. Assumes an Owid Table with entityName.
toPrettyCsv(
//
useShortNames: boolean = false,
activeColumnSlugs: string[] | undefined = undefined
): string {
const activeColumnsDiff: Set<string> = activeColumnSlugs
? differenceOfSets([
new Set(this.columnSlugs),
new Set(activeColumnSlugs),
])
: new Set()
const columnSlugsToRemove = differenceOfSets([
activeColumnsDiff,
new Set([
let table
if (activeColumnSlugs?.length) {
table = this.select([
OwidTableSlugs.year,
OwidTableSlugs.day,
this.entityNameSlug,
]),
])
return this.dropColumns([
OwidTableSlugs.entityId,
OwidTableSlugs.time,
OwidTableSlugs.entityColor,
...columnSlugsToRemove,
])
...activeColumnSlugs,
])
} else {
table = this.dropColumns([
OwidTableSlugs.entityId,
OwidTableSlugs.time,
OwidTableSlugs.entityColor,
])
}
return table
.sortBy([this.entityNameSlug])
.toCsvWithColumnNames(useShortNames)
}
Expand Down

0 comments on commit ff311ee

Please sign in to comment.