Skip to content

Commit

Permalink
Remove incremental CSV load (breaks GZIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
nofurtherinformation committed Feb 7, 2024
1 parent ad69ba2 commit 6104b3e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions utils/data/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,26 @@ export class DataService {

this.data[config.filename] = {};
const dataStore = this.data[config.filename]
P.parse(config.filename, {
P.parse<Record<string,any>>(config.filename, {
download: true,
header: true,
dynamicTyping: true,
step: (row) => {
// @ts-ignore
dataStore[row.data[config.id]] = row.data;
},
complete: () => {
complete: (results) => {
const data = results.data;
if (!dataStore) {
console.error(`No data store for ${config.filename}`);
return;
}

for (let i=0; i<data.length; i++) {
const row = data[i];
if (!row?.[config.id]) {
console.error(`Row ${i} in ${config.filename} is missing a valid id`);
continue;
}

dataStore[row[config.id]] = row;
}
console.log("All done!");
if (this.completeCallback) {
this.completeCallback(config.filename);
Expand Down

0 comments on commit 6104b3e

Please sign in to comment.