Skip to content

Commit

Permalink
Fix #143
Browse files Browse the repository at this point in the history
  • Loading branch information
Merlin04 committed Jul 10, 2021
1 parent ee59075 commit d8a30c7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/blocks/DataFrame.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import Papa from "papaparse";

function parseNumberWithFallback(n: string) {
const parsed = Number(n);
return isNaN(parsed) ? n : parsed;
}

export class DataFrame {
data: any[][] | undefined;
headers: string[];
Expand All @@ -22,8 +27,8 @@ export class DataFrame {
const headers = parsedData[0];

const dataset = parsedData
.map((element) => String(element).split(",").map(Number))
.slice(1, parsedData.length);
.slice(1, parsedData.length)
.map((row) => row.map((cell) => parseNumberWithFallback(cell)));

this.headers = headers;
this.data = dataset;
Expand Down

0 comments on commit d8a30c7

Please sign in to comment.